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!

Make values string out across a line instead of on separate rows

Status
Not open for further replies.

dean12

MIS
Oct 23, 2001
273
US
Got a simple table like this:

DeptNo
EmployeeName

I want to produce a report that looks like this:

Accounting Susan, Andy, Bill, Frank
Marketing Mark, Bill, Bill, James, William

rather than:

Accounting Susan
Accounting Andy
Accounting Bill

.
. etc
.

Any hints on how to build up such a string of names?
 
If in combination they don't exceed 254 characters, and assuming that you're grouped by Department:

Create a formula in the dept group header like:
whileprintingrecords;
stringvar MyNames := "";

Create a formula in the detail section to concatenate the names like:
whileprintingrecords;
stringvar MyNames;
If {MyTable.MyName} <> &quot;&quot;
MyNames := MyNames+&quot;, &quot;+{MyTable.MyName}

Create a formula in the dept group footer like:
whileprintingrecords;
stringvar MyNames;
MyNames

Suppress the group header and the detail section.

-k kai@informeddatadecisions.com
 
I used the formula's to build a string of applications with a carriage return in between each (see below); however, it always has the carriage return at the beginning of the string.

I know his is b/c Applications is null to start, thus making the first entry a carriage return - I just can't figure out how to make it stop. . .

@hdrApplication in Group Header
whileprintingrecords;
stringvar strApplications := &quot;&quot;;

@dtlApplication in Detail Section
whileprintingrecords;
stringvar strApplication;
If {APPLICATION.DESCRIPTION} <> &quot;&quot; then
strApplication := strApplication + CHR(010) + {APPLICATION.DESCRIPTION}

@ftrApplication in Footer Section
whileprintingrecords;
stringvar strApplication;
strApplication

- - tx Ko'lee
 
Well just when I gave up.. the answer came to me. I added an if/else to the detail to check if the string is empty <see below>

@hdrApplication in Group Header
whileprintingrecords;
stringvar strApplications := &quot;&quot;;

@dtlApplication in Detail Section
whileprintingrecords;
stringvar strPhase;
If (strPhase <> &quot;&quot; and {STATUS.DESCRIPTION} <> &quot;&quot;) then
strPhase := strPhase + CHR(010) + {STATUS.DESCRIPTION}
else
strPhase := {STATUS.DESCRIPTION};

@ftrApplication in Footer Section
whileprintingrecords;
stringvar strApplication;
strApplication

- ko'lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top