gsuresh17
asked on
Invalid Array subscript in Crystal Reports 9
I use Arrays in my formula in CR 9. But when I try to get an value from that array I get an error saying "A subscript must be between 1 and the size of the array". The subscript which I gave is a valid one. Below is the code snippet. Any help appreciated. This is in crystal syntax
Formula 1:
Shared NumberVar Array E := [0,0,0,0] ;
If ( some condition ) then
E [1] := database field value
Else If ( condition ) then
E [2] := database field value
--------------
Formula 2:
Shared NumberVar Array E ;
E [2]
--------------
Also I tried to store the Ubound of this array in a numbervar, but I get 0 for that.
Formula 1:
Shared NumberVar Array E := [0,0,0,0] ;
If ( some condition ) then
E [1] := database field value
Else If ( condition ) then
E [2] := database field value
--------------
Formula 2:
Shared NumberVar Array E ;
E [2]
--------------
Also I tried to store the Ubound of this array in a numbervar, but I get 0 for that.
ASKER
Formula2 gives the error. I had given the EvaluateAfter function in formula2 earlier. Even though I get that. I missed to give that in this code snippet..
Where is formula 1 placed in the report? Formula2?
mlmcc
mlmcc
ASKER
I have placed formula1 in Group header 1 and suppressed it
Formula 2 is in the detail section?
mlmcc
mlmcc
ASKER
In the same Group Header 1 but not suppressed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I don't have an Group2 in my report. Anyway I got the logic of evaluation.
I meant group 1 (fat fingers strikes again)
Glad i could help
mlmcc
Glad i could help
mlmcc
which section(s) of the report contain the formulas ? formula 2 needs to be evaluated after formula 1 so you will either need to place formula 2 in a section below formula 1 or set the evaluation time of the formulas
amend your formulas to be
Formula 1:
WhilePrintingRecords;
Shared NumberVar Array E := [0,0,0,0] ;
If ( some condition ) then
E [1] := database field value
Else If ( condition ) then
E [2] := database field value
--------------
Formula 2:
EvaluateAfter({@Formula1})
Shared NumberVar Array E ;
E [2]
Gary