Printing date range parameters in the report header wasn't too difficult, but I had a hard time figuring out how to print multiple discrete and range parameter values in Crystal Reports Version 8.5.
I spent a long time searching through the posts and FAQs on this website and the articles in Crystal Care Technical Support, but I kept running into the errors: "a number, currency amount, boolean, date, time, date-time, or string is required here" and the infamous "the result of a formula cannot be an array."
Finally, I found the Crystal Reports 7 article c2005435 at
http://support.crystaldecisions.net/library/kbase/articles/c2005435.asp
which led me to my final solution. The three formulas below use Crystal Syntax in Crystal Reports Version 8.5.
Formula @DateRange is for printing a simple date range.
Formula @CompanyRange is for printing NUMERIC multiple discrete and range parameter values.
Formula @FaultRange is for printing STRING multiple discrete and range parameter values.
Note that the @CompanyRange and @FaultRange are very similar except that the empty value for numeric arrays is "0", while the empty value for string arrays is "".
The last line of each formula removes the final ", ".
// Formula @DateRange
// - Prints Date Range in Header
// - Samples:
// Dates from 10/01/01 to 10/25/01
// Dates from First to 10/25/01
// Dates from 10/01/01 to Last
//
WhilePrintingRecords;
if ToText(Minimum({?DateParam})) = "" then
"Dates from First to " +
ToText(Maximum({?DateParam}))
else
if ToText(Maximum({?DateParam})) = "" then
"Dates from " + ToText(Minimum({?DateParam})) +
" to Last"
else
"Dates from " + ToText(Minimum({?DateParam})) +
" to " + ToText(Maximum({?DateParam}));
// Formula @CompanyRange
// - Prints Company Ranges in Header
// - Note: parameter {?Company} is NUMERIC
// - Sample:
// Companies: First to 103, 106, 112 to 118, 127 to Last
//
WhilePrintingRecords;
StringVar CompRange := "Companies: ";
NumberVar CompCount := Count({?Company});
NumberVar x;
For x := 1 to CompCount
Step +1
Do (if ToText(Minimum({?Company}[x])) = "0" then
CompRange := CompRange +
"First to " +
ToText(Maximum({?Company}[x]))
+ ", "
else
if ToText(Maximum({?Company}[x])) = "0" then
CompRange := CompRange +
ToText(Minimum({?Company}[x]))
+ " to Last, "
else
if ToText(Minimum({?Company}[x])) =
ToText(Maximum({?Company}[x])) then
CompRange := CompRange +
ToText(Maximum({?Company}[x]))
+ ", "
else
CompRange := CompRange +
ToText(Minimum({?Company}[x]))
+ " to " +
ToText(Maximum({?Company}[x]))
+ ", "
);
CompRange := Left(CompRange,Length(CompRange) - 2);
// Formula @FaultRange
// - Prints Fault Code Ranges in Header
// - Note: parameter {?FaultCode} is a STRING
// - Sample:
// Fault Codes: First to C, F, J, M to P, S to Last
//
WhilePrintingRecords;
StringVar FaltRange := "Fault Codes: ";
NumberVar FaltCount := Count({?FaultCode});
NumberVar x;
For x := 1 to FaltCount
Step +1
Do (if ToText(Minimum({?FaultCode}[x])) = "" then
FaltRange := FaltRange +
"First to " +
ToText(Maximum({?FaultCode}[x]))
+ ", "
else
if ToText(Maximum({?FaultCode}[x])) = "" then
FaltRange := FaltRange +
ToText(Minimum({?FaultCode}[x]))
+ " to Last, "
else
if ToText(Minimum({?FaultCode}[x])) =
ToText(Maximum({?FaultCode}[x])) then
FaltRange := FaltRange +
ToText(Maximum({?FaultCode}[x]))
+ ", "
else
FaltRange := FaltRange +
ToText(Minimum({?FaultCode}[x]))
+ " to " +
ToText(Maximum({?FaultCode}[x]))
+ ", "
);
FaltRange := Left(FaltRange,Length(FaltRange) - 2);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.