Print Page | Close Window

Array Must be Subscripted Error

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22908
Printed Date: 18 Apr 2024 at 1:45am


Topic: Array Must be Subscripted Error
Posted By: rcoxe
Subject: Array Must be Subscripted Error
Date Posted: 14 Oct 2020 at 4:49am
I have a parameter to allow the user to enter which warehouse they want to use for the report. I also have a formula to display the warehouse specified, or, if none is specified, then return "All". I am trying to make this parameter accept multiple values but when I do this, I get an error in my formula:

"This array must be subscripted. For example: Array "

I have changed my formula to show one of the values but cannot figure out how to get it to display all of the values.

Currently my formula is:

"IF(NOT(HasValue({?Warehouse@SELECT WhsCode FROM OWHS}))) THEN "All" ELSE {?Warehouse@SELECT WhsCode FROM OWHS}[1]"

How can I modify this formula to show all values entered in the parameter?

Thanks



Replies:
Posted By: lockwelle
Date Posted: 20 Oct 2020 at 5:34am
I am guessing that the parameter is from the Crystal Report parameter screen.

To return all the selected options, I usually use:
local numbervar j;
local stringvar selected:="";

for j:= 1 to ubound({?parameter})
   selected := selected + ", " + {?parameter}[j];

selected



since the parameters are an array, you could also use:
join({?parameter}, ",")

HTH


Posted By: rcoxe
Date Posted: 21 Oct 2020 at 8:55am
That did it. Thanks lockwelle.



Print Page | Close Window