[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Invalid Array subscript in Crystal Reports 9

Posted on 2004-11-12
9
Medium Priority
?
635 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:gsuresh17
  • 4
  • 4
9 Comments
 
LVL 19

Expert Comment

by:GJParker
ID: 12567517
you don't say which formula is giving you the error  ? formula 1 or formula 2

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
0
 

Author Comment

by:gsuresh17
ID: 12567786
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..
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12567919
Where is formula 1 placed in the report?  Formula2?

mlmcc
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:gsuresh17
ID: 12567947
I have placed formula1 in Group header 1 and suppressed it
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12568500
Formula 2 is in the detail section?

mlmcc
0
 

Author Comment

by:gsuresh17
ID: 12568881
In the same Group Header 1 but not suppressed.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 375 total points
ID: 12571843
Try this.

Open the report
delete formula2 from the group1 header
Reinsert formula2 into the group2 header.

Crystal, in its infinite wisdom, uses order of insertion into the report to determine order of evaluation.  By putting formula2 in last you guarantee the formula1 is evaluated first.

mlmcc
0
 

Author Comment

by:gsuresh17
ID: 12587717
I don't have an Group2 in my report. Anyway I got the logic of evaluation.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12589798
I meant group 1 (fat fingers strikes again)

Glad i could help

mlmcc
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question