Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Merge records into continuous string Post Reply Post New Topic
Author Message
JennyB
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 24
Quote JennyB Replybullet Topic: Merge records into continuous string
    Posted: 08 Jan 2013 at 2:09am
Hi,

I have a report which pulls scoreboard messages. These are all held in separate records in a table. For my report output I want to merge these into one single continuous line of text (with a couple of spaces between), so from the original data which is like this:

Message
Message1
Message2
Message3
...

I want to convert it to report output like this:

Message1  Message2  Message3 ...

Any ideas? :) I'd be delighted if its something really obvious and its just me..

Thanks!


Edited by JennyB - 08 Jan 2013 at 2:11am
IP IP Logged
JennyB
Newbie
Newbie


Joined: 26 Dec 2012
Online Status: Offline
Posts: 24
Quote JennyB Replybullet Posted: 08 Jan 2013 at 3:28am
:) A bit more scouting and I found the answer from here, its ingenious and it concatenates all my records onto one line in my report footer exactly as I wanted them, hooray!:

http://forums.codeguru.com/showthread.php?524357-RESOLVED-Multiple-Rows-to-a-single-row

Study the next solution, where we are concatenating a field and display the resulting string at group or report footer in only one line

To do that, you have to create 3 formulas:

The first one, let's call it @null:
Code:
whileprintingrecords;
stringvar names := "";
Place it in your GH section, it will return you null.



The second one, let's say @comma_field:
Code:
whileprintingrecords;
stringvar names;
names := names & ", " & {table.field};
Place it in your Detail section which you can suppress; the formula will return you next:
, Jules, Christina, Paul


and the 3rd formula, let's call it @final (or whatever you like):
Code:
whileprintingrecords;
stringvar names;
Mid(names, 3);
Place it in your GF or report footer section.
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.