Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Multiple Fields into one string per group Post Reply Post New Topic
Author Message
jessewithag
Newbie
Newbie


Joined: 25 Jun 2018
Location: United States
Online Status: Offline
Posts: 6
Quote jessewithag Replybullet Topic: Multiple Fields into one string per group
    Posted: 02 Apr 2019 at 8:18am

Hello,
I currently have a report with groups that look like the following:
1
                              
1000      02/01/19      02/08/19     31     REG     7         1
1000      01/01/19      02/08/19     30     REG     38        5
1000      12/01/18      02/08/19     29     REG     69        7
1000      11/01/18      02/08/19     28     REG     99        7
1000      10/01/18      02/08/19     27     REG     130      7
1000      09/01/18      02/08/19     26     REG     160      7
1000      08/01/18      02/08/19     25     REG     191      7

I would like to get the fields in the last column into the group header in a single field for each individual group, ex this group would return 1577777, the same as the list of records above in the last column so the data would read

1 1577777
                              
1000      02/01/19      02/08/19     31     REG     7         1
1000      01/01/19      02/08/19     30     REG     38        5
1000      12/01/18      02/08/19     29     REG     69        7
1000      11/01/18      02/08/19     28     REG     99        7
1000      10/01/18      02/08/19     27     REG     130      7
1000      09/01/18      02/08/19     26     REG     160      7
1000      08/01/18      02/08/19     25     REG     191      7

Any help is appreciated. Thanks.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 Apr 2019 at 4:10am
I think of only two ways to do this.  One create a command that creates the string with SQL code (probably as a second data source).  Two create a subreport that creates the string and passes back the value to the main report.
IP IP Logged
jessewithag
Newbie
Newbie


Joined: 25 Jun 2018
Location: United States
Online Status: Offline
Posts: 6
Quote jessewithag Replybullet Posted: 03 Apr 2019 at 6:18am
Hello, I was able to resolve the issue after searching many different forums.

I had to add a variable to each group from header to details to footer that collected the fields while printing records in the group and then produced them into the Group Footer, instead of the Group Header.

GHeader:
WhilePrintingRecords;
StringVar ConcatenatedID;
If Not InRepeatedGroupHeader Then
    ConcatenatedID := "";

Details:
WhilePrintingRecords;
StringVar ConcatenatedID := ConcatenatedID + {Field};

GFooter:
WhilePrintingRecords;
StringVar ConcatenatedID;

This produced a string variable which I then reversed and changed to number, and then back to string so i could add leading zeroes. Also, in the records that were read and put into the string, I had some fields that were suppressed and still got picked up into the string. To resolve this I had to also create a formula to match the suppression conditions and changed the pulled field to a null value so my string wasn't affected.

Thanks for the assistance and advice, this is my first thread but I lurk quite a bit learning things here and there.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 03 Apr 2019 at 10:15am
I had thought of a solution like that, but was not sure if it would display properly.  Not sure why you would have to change it to a number then back to a string.  There are ways to format to get leading zeros on strings.
IP IP Logged
jessewithag
Newbie
Newbie


Joined: 25 Jun 2018
Location: United States
Online Status: Offline
Posts: 6
Quote jessewithag Replybullet Posted: 10 Apr 2019 at 6:24am
for some reason when i reloaded the report without saving data there was an error with the section of the formula highlights but showed no errors in checking the syntax. Not sure if doing the conversion all at once and calculating the field was too much for crystal but after i split it up, the false errors stopped.
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.016 seconds.