Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Display rows into column position Post Reply Post New Topic
Author Message
siska
Newbie
Newbie


Joined: 22 Oct 2007
Location: United States
Online Status: Offline
Posts: 1
Quote siska Replybullet Topic: Display rows into column position
    Posted: 22 Oct 2007 at 3:39pm

I am working CRYSTAL XI. I am getting confused about merging 2 tables. at the report leve. I have 2 tables 1) msg_tbl 2) msg_err_tbl. Msg_tbl is primary key of msg_id & msg_err_tbls has primary key of (MSG_ID + SEQ#). Seq# 1, 2.. to store more than one error message in the error message table.

Table Example:
MSG_TBL
------------
MSG_ID
 
MSG_ERR_TBL
------------------
MSG_ID
SEQ_NUM
error_reason
 
Final report should display one row for each message_id with the maximum of 3 error_reason ( which is coming from msg_err_tbl)
 
Since Error_msg_table.error_reason will be stored as a different rows, can you help me to bring these error_reasons at single row level on crystal report??
 
Thank you..
 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 25 Oct 2007 at 11:35am
I'm confused on the table structure of MSG_ERR_TBL. Are the three fields that you listed part of the same record, or is the error_reason somehow in a different record than SEQ_NUM? I would think they have to be in the same table, but you say that you need to bring them into a single row. But if they are all on different rows, they how are the linked to the parent table?
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 26 Oct 2007 at 2:23am

Hi ....

Create a UDF I have tested it on sql server 2000
 
CREATE FUNCTION dbo.UDF_Messagedetail1
( @MsgID char(1) )
RETURNS varchar(1000)
AS
BEGIN
DECLARE @MsgDetail varchar(1000), @Delimiter char
SET @Delimiter = '+'
SELECT @MsgDetail = COALESCE(@MsgDetail + @Delimiter, '') + strPQ
FROM
(SELECT  MSG_ID,Message,'('' * ' + LTRIM(Message) + ')' AS strPQ
FROM         dbo.MSG_TAB inner join MSG_DET on [ID] = @MsgID) derived
WHERE
MSG_ID=@MsgID
RETURN ( SELECT REPLACE(@MsgDetail,')+(',') + (') AS [Message_Detail])
END
 
Once you have done that run sql statement
select distinct(MSG_ID), dbo.UDF_Messagedetail1(MSG_ID) AS Message
From dbo.MSG_TAB
 
You will get the results
 
 
1          (' * MSG1     ) + (' * MSG2     ) + (' * MSG3     )
2          (' * MSG1     ) + (' * MSG2     ) + (' * MSG3     )
3          (' * MSG1     ) + (' * MSG2     ) + (' * MSG3     )
4          (' * MSG1    )

 
Test Tables
 
MSG_TAB Table
 
ID Message
1  MSG1
1  MSG2
1  MSG3
2 MSG1
2 MSG2
2 MSG3
3 MSG1
3 MSG2
3 MSG3
4 MSG1
 
MSG_DET  Table
 
ID
1
2
3
4
 
 
 
You can easliy create a view or table at backend using sql and the access then using Crystal
 
Cheers
Rahul


Edited by rahulwalawalkar - 26 Oct 2007 at 2:26am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.