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

Crystal Report Arrays created from a parameter

Status
Not open for further replies.

Tylendal

Programmer
Jun 20, 2010
1
US
I'm using Crystal Report 10 and have created a parameter called {?SalesMonths}. This parameter allows the user to select from 1 to 12 months.

The attached code is for the formula {@DispMonth} that is not working. This formula is to display the name of the months selected (monthname) is Crystal Report function. The formula throws no errors when being compiled but when run the lengh of the array is causing a problem. Using 12 as the number of elements in the array is only correct if all 12 months are selected.

I'm not sure how to get the array length or number of elements in the array. Using {?SalemsMonths}.length does not compile. If I select only 3 months and hard code {?SalesMonths}(3) the code runs but nothing is displayed.

I assume this means the For Next loop either does not run or is not collecting data. Not sure if the "monthname" is causing the problem or not.

HELP!!!! I'm stumbling on creating and using a simple one dementional array.

Code:
Global SalesMonths({?SalesMonths}(12)) as number
Global DispMonth as string
Global i as number
DispMonth=""
for i=salesmonths(1) to salesmonths(12) step 1
if i >0 then
DispMonth=DispMonth & ", " & monthname(i)
end if
next i
formula=DispMonth
 
Change your formula to (using Crystal syntax):

numbervar array SalesMonths := {?SalesMonths};
stringvar dispMonth := "";
numbervar i;
numbervar j := ubound({?SalesMonths});
for i := 1 to j do(
if {?SalesMonths} > 0 then (
dispMonth := dispMonth + monthname({?SalesMonths}) + ", "
));
if len(dispMonth) > 2 then
left(dispMonth, len(dispMonth)-2)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top