Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Concatenating data of different records Post Reply Post New Topic
Author Message
geri
Newbie
Newbie
Avatar

Joined: 19 Jun 2007
Location: Singapore
Online Status: Offline
Posts: 2
Quote geri Replybullet Topic: Concatenating data of different records
    Posted: 19 Jun 2007 at 7:50pm
Hi,

I am a newbie to crystal report and i am facing some problem in concatenating data fields of 2 rows.. anyone can help me?

I have a record which is having multiple rules from the rule table based on a record ID.. and i need to concate the rules together and return as a single data for the particular record for display in the detail section..

not sure how to accomplish this.. anyone can help me??

many thks in advance.. Smile
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Jun 2007 at 8:25pm
If you're a total newbie, you probably need to read my free online chapters to get the full details of how to do some of these tricks in CR.

To concatenate data, create a string variable and use the & to join multiple fields together. Create a new formula and put code similar to the following in it (change the table and fields for your purposes).

StringVar AllRules;
AllRules := {table.Rule1} & ", " & {table.Rule2} & ", " & {table.Rule3};



Edited by BrianBischof - 19 Jun 2007 at 8:26pm
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
geri
Newbie
Newbie
Avatar

Joined: 19 Jun 2007
Location: Singapore
Online Status: Offline
Posts: 2
Quote geri Replybullet Posted: 19 Jun 2007 at 9:34pm
ehmm...

is a 1:M relation (2 tables)

the solution you gave me seems only dealing with 1 table.. ehmm...
i need to use looping..


whileprintingrecords;
global stringvar ruleName;

if ruleName = "" then
    ruleName := {table.RuleName}
else
    ruleName := ruleName & "/" & {table.RuleName}




this formula will return me below (if i got 1 record having 3 rules):

record1      rule1
record1      rule1/rule2
record1      rule1/rule2/rule3      (3 rows)


but i want it to look like this
record 1      rule1/rule2/rule3      (1 single row ONLY)
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 20 Jun 2007 at 12:45am
I was worried you might come back and say that. Well, at least you understood well enough to get it implemented correctly!

The next step is to use a subreport with a global variable. Let the subreport do the looping through the records and behind the scenes build the string variable. Since it is global you can then use it on the main report. The problem is going to be with the subreport screwing up the formatting of the main report. Try suppressing the sections of the subreport (this might not work, I'm not certain). Another option is to make the text of the subreport white so that it isn't visible and on the main report use Overlay section so that the subreport doesn't take up much space.

Those are some ideas for you.
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
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.