This one is a real zinger. I'm using Crystal 8.5. I have created a parameter field named PL which is setup as such:
string value type
allow multiple values
discrete and range values
Now, the user will typically enter values such as:
01 (discrete)
02 (discrete)
03 10 (range)
The report accepts these multiple discrete and range values and shows the results with no issues.
I want to show all of the parameter values in a title. I know how to create a formula and place it on the report.
But the question is how do I construct the formula given how I have setup this particular parameter field?
After much research, here is what I have tried so far and none of my attempts pass the formula editor check for various reasons:
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
-- Crystal Syntax
StringVar strResult := '';
NumberVar n;
for n := 1 to ubound({?PL})
do
(
strResult := strResult + {?PL}[n];
); ^--------------- A string is required here.
strResult
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
-- Crystal Syntax
StringVar strResult := '';
NumberVar n;
for n := 1 to ubound({?PL})
do
(
strResult := strResult + ToText( {?PL}[n] );
); ^----------------- A number, currency amount, boolean, date, time, date-time, or string is required here.
strResult
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
-- Crystal Syntax
Join( {?PL},"," )
^--------------- A string array is required here.
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
-- Crystal Syntax
Join(ToText( {?PL} ),"," )
^----------------- A number, currency amount, boolean, date, time, date-time, or string is required here.
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
-- Basic Syntax
dim i as number
dim s as string
for i = 1 to UBound({?PL})
s = s & Chr(13) & chr(10) & {?PL}(i)
^----------------- A number, currency amount, boolean, date, time, date-time, or string is required here.
next
formula = s
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
-- Crystal Syntax
//Declare a variable to hold the number of items in the Multiple value parameter
Global NumberVar Counter := Count({?PL});
//Declare a variable to use in the For Loop
Global NumberVar i :=1;
//Declare a string variable to hold the resulting string
Global StringVar Display;
//Loop through all of the items in the parameter.
//Extract each and add to a string
For i := 1 to Counter Do
(
//Add the first parameter value to the Display variable
If i = 1 then
({?PL}[i];
Display := Display + {?PL}[i])
^--------------- A string is required here.
//Add a comma to the Display variable before adding subsequent parameter values
Else If i < Counter then
({?PL}[i];
Display := Display + ", ";
Display := Display + {?PL}[i])
//Add the word 'and' to the Display variable before the last value rather than a comma
Else
({?PL}[i];
Display := Display + " and ";
Display := Display + {?PL}[i])
);
//Display the variable that holds the result
Display
-=-=-=-=-=-=-=-=-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=-=-=-=
-=-=
Thanks in advance,
Preece
Start Free Trial