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

String Array formula Crystal Reports v10

Status
Not open for further replies.

golfnut64

Technical User
Aug 17, 2005
3
US
I have a field and I want to string the data see example below

CONSOL_NUMB CUST_PO
1000738 64905400
1000738 64905380

I want the string to be like example below

CONSOL_NUMB CUST_PO
1000738 64905400,64905380

I keep getting a string array should be used here but I don't know how to use it please help.
 
You don't need an array. Group by CONSOL_NUMB. Suppress the details. Collect the codes.

I did something similar for postcodes: you should be able to adapt it.
Code:
Accumulate postcodes for groups
// Accumulate using a formula field (suppressed) in the detail line.  Allow for nulls and blanks.
whileprintingrecords;
if not isnull({Recc.Postcode}) and {Recc.Postcode} <> " "
then stringvar pst := pst + {Recc.Postcode} +", "
else if length(pst) = 0 
then stringvar pst := pst + "Excluding blanks; "
else stringvar pst := pst 

// Show in using a formula field in the group footer.
whileprintingrecords;
stringvar pst;
left(pst,len(pst)-2)

//  Clear using a formula field using in the group header.
whileprintingrecords;
stringvar pst := "";

Note that clearing in the footer avoids problems with group headers repeating on a new page, which does clear everything for the group. Provided the 'clear' is placed in the section AFTER the display, it will do them in that order.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
I'd adjust this slightly and add in the ability to dedupe and other minor differences:

Group Header formula (suppress this section):
whileprintingrecords;
stringvar pst:="";

Details Formula (suppress this section):
whileprintingrecords;
stringvar pst;
if not isnull({Recc.Postcode}) and trim({Recc.Postcode})<> ""
and
not({Recc.Postcode} in pst) then
pst:=pst & {Recc.Postcode} & ", "

Group Footer formula (where everything is displayed):
whileprintingrecords;
stringvar pst;
left(pst,len(pst)-1)

We could also have used an array.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top