Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display only one field record horizontally in crystal report

Status
Not open for further replies.

Kofstar

Technical User
Jun 8, 2020
6
AU
Hi all,
I'm very new to this platform but found it very great and hoping someone can help me with my query.

I'm not sure how to ask this question but will give it me best.
I'm writing a report which is displaying a field with multiple values vertically hence duplicating it - example below:

1. John Smith Never smoked
2. John Smith Patient Information and referral to Quitline
3. Neena Pratt Ex-smoker
4. Neena Pratt Patient informed and refused Quitline referral

I want this displayed as:
1. John Smith Never smoked Patient Information and referral to Quitline
2. Neena Pratt Ex-smoker Patient informed and refused Quitline referral

Many thanks

Kofstar
email: kofiattrams@yahoo.com.au
 
The big issue is pulling out the name on the string. There is no reliable way of doing that (First Name-Last Name, Firat Name-Middle Name-Last Name, First Name-Last Name with a space or a hyphen, First Name with a space or hyphen-Last Name, etc.). But if it was not for that then the code below would work.

First formula, goes in the group header.
shared stringvar displaystr := ''; (you could used a global variable, but I like using shared variables)

Second formula, goes in the detail section which is hidden.

shared stringvar displaystr;

if len(displaystr) = 0 then
displaystr := {somestring}
else
displaystr := displaystr + ' ' + {somestring}


last formula, that goes in the group footer.
shared stringvar displaystr;


Of course you would replaced {somestring} with the field value that has the string you want to build.
 
Hello Kray,

Big thanks. This worked well. One more thing, any chance of not lumping them together but rather them as separate columns i.e. column 1 column 2 column 3 etc?

 
Well I think there would be a round about way. But you would have to know the maximum number of columns that are needed ahead of time (it would have to be under 100). And the code would be messy.

I am think that you might be able to do an array and some formulas (one for each column, and a couple of support formulas). I have not tried doing it yet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top