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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data returned horizontally with commas 1

Status
Not open for further replies.

Garyjr123

MIS
Sep 14, 2010
139
US
Is there a good formula to use to return the queried data in my report back horizontally separated by commas instead of being listed vertically?
 
Hi,
One way would be to create a formula to concatenate the fields in the report with commas as needed:
@CSV
Code:
{table.field1}+ "," + {table.field2} + "," ....

Place this formula in the report instead of the actual fields.
NOTE: If any of the fields can be NULL, test for that before including that field in the concatenated string.

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks Turkbear for the quick response but I have a few questions. Does this concatenate all the data returned for the field or just the number of fields I specify? So, if I have a field for medication names (say 15 different medicaitons) and want to return the medication names horizontally with a comma between each name will this automatically do that for every med or do I need to specify in the formula the number of meds I want horizontally with a comma?
 

Hi,
No, that would require concatenating multiple records not multiple fields from the same record.

This thread contains a solution by lbass that should show you the way:

thread767-1263598


[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
To simply that a bit, you could do this:

//{@reset}-- if you want the comma-delimited result per some group, place this in the group header:

whileprintingrecords;
stringvar x;
if not inrepeatedgroupheader then
x := "";

//{@accum} to be placed in the detail section:
whileprintingrecords;
stringvar x := x + {table.medication}+",";

//{@display} for the group footer (or report footer if no group):
whileprintingrecords;
stringvar x;
if len(x)>1 then
left(x,len(x)-1)

-LB
 
In the thread you provided, it seems like he is concatenating fields of different tables when I want to concatenate the rows returned for that field. Also, can I use this in a subreport?
 
Did you see my post? This is concatenation across records from one field. Yes, you can do this in a subreport if you wish.

-LB
 
Sorry LB, I didn't. I ended up sending that after reading your post. Thank you for your help. Being somewhat of a novice, I have the fields I want to pull in the subreport but no group headings, just a report header and details section. Does this change your post?
 
If you don't have any groups, then you just can eliminate the reset formula.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top