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

Displaying records horizontally without spaces in between

Status
Not open for further replies.

rollypac

Programmer
Jun 13, 2003
23
0
0
US
I am pulling children's names into my report using a sub report. I can get the names to print horizintally but they need to be separated by a comma with only one space between and parans around all names. This is what I am getting:
Lisa Richard Troy Jason

I need it to look like this:
(Lisa, Richard, Troy, Jason)

Any suggestions would be greatly appreciated.
 
I'm guessing these are from different records and you have used multiple columns to format the names in a row. If this is the case, you could do the following:

Let's assume that you have a group based on a field like {table.parent} and you want to list the names of the children below. Create three formulas:

{@resetnames} to be placed in the group header:
whileprintingrecords;
stringvar names := "";

{@detailnames} to be placed in the detail section:
whileprintingrecords;
stringvar names := names + {table.childname}+ ", ";

{@displaynames} to be placed in the group footer:
whileprintingrecords;
stringvar names;
left(names,len(names)-2);

Then suppress the details.

-LB
 
To get the parans around the names, alter LB's last formula to :

{@displaynames} to be placed in the group footer:
whileprintingrecords;
stringvar names;
"("&left(names,len(names)-2)&")";

Reebo
Scotland (Sunny with a Smile)
 
I am getting multiple family records when I use your suggestions.
The family name is in one table and the individual names are in another.
I have grouped on the family name.

It should look like this
Banks, John & Lisa Richard, Linda

I get
Banks, John & Lisa John
Banks, John & Lisa John, Lisa
Banks, John & Lisa John, Lisa, Richard
Banks, John & Lisa John, Lisa, Richard, Linda
Any other sugestions?
 
You should be placing the display value in the group footer and suppressing the details. This would give you:

Banks, John & Lisa John, Lisa, Richard, Linda

And I guess you want it to look like:

Banks, John & Lisa (Richard, Linda)

In other words, your "child" table also has the parents' names included in it? Is there a code in the child table that identifies parents versus children?

By adding Reebo's suggestion to mine, you would already have the parentheses, so the problem now is how to remove the parents' names from the variable.

How did you get the display &quot;Banks, John & Lisa&quot;? Is this a combination of fields or one field? If the parent table has a separate field for first name, you might be able to add a condition into the variable that states that {parent.firstname} <> {child.firstname}, but I can't tell without more information about your fields...

-LB
 
&quot;Banks, John & Lisa&quot; is a field called fam_nam in the parent table. The first and last names of all individuals are in the child table with a field that specifies their relationships.
The only way I have been able to pull the kids names into a report without getting multiple records is to use a sub report.
 
I think you could just do the following:

{@resetnames} to be placed in the group header:
whileprintingrecords;
stringvar names := &quot;&quot;;

{@detailnames} to be placed in the detail section:
whileprintingrecords;
stringvar names;
if {table.relationships} <> &quot;parent&quot; then
names := names + {table.name} + &quot;, &quot; else
names := names + &quot; &quot;; //two spaces between the quotes
&quot;(&quot;&left(names,len(names)-2)&&quot;)&quot;;

{@displaynames} to be placed in the group footer:
whileprintingrecords;
stringvar names;
&quot;(&quot;&left(names,len(names)-2)&&quot;)&quot;;

Just substitute the field that identifies the relationship and the correct value of that field in the detail formula.

-LB
 
I appreciate all your time.
I can now get the kids names to look like I want but I am still getting multiple records. It displays a record for each individual and if there is more than 1 kid it just keeps adding their names to the next persons record.

I get
Banks, John & Lisa
Banks, John & Lisa
Banks, John & Lisa (Richard)
Banks, John & Lisa (Richard, Linda)
 
On what field is your subreport linked to your main report? I assumed it was a family name field or family ID. If you group on this in the subreport, and place the display formula in the subreport group footer, you should get only one line with the children's names. The reset formula should be in the subreport group header (family name). Suppress all subreport sections except the group footer, and then place the subreport in the group footer for family name in the main report.

If your report and subreport layout is different, please explain in more detail. I think we've almost got it...

-LB
 
Thank you, I finally got it to work!!!! I'm not sure what I was doing wrong before but thank you very much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top