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

Multiple parameter values in report header 1

Status
Not open for further replies.

deemat

MIS
Jan 20, 2006
24
US
I am trying to show all the values that are chosen in a multiple value parameter in the report header. I tried using Join({?parameter},','). But I keep geting the error "A string array is required here". The values in the parameter are strings but it still doesn't work. Any help would be greatly appreciated.
 
In the field explorer, Special Fields there is a field called "record selection formula" this shows both the criteria and parameters -
it looks like this, parameters start "?"

{@EXC ADD OUT OF RANGE} = "OK" and{@hau in range} = "OK" and{@COMP START} >= DateTime (2012, 06, 01, 00, 00, 00) and{FRT.LINE} = "MAERSK" and{FRT.ORIGIN} = {?Query on - ORIGIN} and{FRT.To} >= DateTime (2012, 01, 01, 00, 00, 00) and{FRT.CNTR SIZE} = {?Query on - CNTR SIZE}
 
for string parameter
stringvar output;
numbervar a;
for a := 1 to ubound({?parameter})
do output := output &{?parameter}[a] & ", " ;
output := left(output,len(output)-2);

for numeric parameter
stringvar output;
numbervar a;
for a := 1 to ubound({?parameter})
do output := output &totext({?parameter}[a],"#") & ", " ;
output := left(output,len(output)-2);

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Unless you are using a very old version of CR, the Join({?parameter},',') approach would work as long as the parameter values are strings.

The error message you quoted suggests that it is not a string parameter, in which case CoSpringsGuy's second approach should work. As is nearly always the case with CR, there are alternative approaches that may or may not be better, depending on circumstances. One such alternative would be to convert the Number Array (the parameter) to a String Array. This could be achieved with the following code:

Code:
WhilePrintingRecords;
Global StringVar Array DISP; 
Local NumberVar i;
Local NumberVar x := UBound({?Parameter});

Redim DISP [x];

For i := 1 to x Do
DISP [i] := ToText({?Parameter}[i], '#');

Join (DISP, ', ')

Probably not necessary in this case, but it is useful to be aware of the alternatives. At the very least it would serve to confirm that the parameter values are actually numbers.

Cheers
Pete
 
Thanks for your help. I tried both formulas but neither worked. I still get the same error. The fields used to create the parameter data types are strings in Crystal reports, I don't know why it's not working.
 
check your parameters ..

what is allow multiple values set to?
what is allow range values set to?

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
I've done it in Crystal 11 by placing this formula in the report header:

//@sstring
shared numbervar I :=1;
shared stringvar dxtab := '' ;
while i <= count({?Diagnoses})
do (dxtab := dxtab +{?Diagnoses};
IF I < count({?Diagnoses}) then dxtab:= dxtab+', ' else dxtab := dxtab ;
I:= I+1)

then this one in the page header:

//@scanfor
shared stringvar dxtab;
"Scan for Diagnosis Codes: "&dxtab

where {?Diagnoses} is a string parameter that allows multiple entries.
 
Nice ...

I implemented your solution because I wanted to see how it works. Really odd though that the string suggestion I sent above didnt work. I JUST tested it side by side with yours and the both work fine. Nothing wrong with your solution at all but the one I sent only requires one formula. Not sure if there is a parameter setting that is different or what.. Regardless... Glad you got it working

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
CoSpringGuy: That post was not from the OP. Given our suggestions did not work there is no logical reason why that one would have.

deemat: Do you still need assistance, or did Charliy's suggestion work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top