Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: How to populate an array Post Reply Post New Topic
Author Message
radibhatla
Newbie
Newbie


Joined: 01 Mar 2010
Location: United States
Online Status: Offline
Posts: 6
Quote radibhatla Replybullet Topic: How to populate an array
     Posted: 21 Apr 2010 at 12:30pm
Hi,
 
Could someone help me with building an array for each row of the calculated value.
 
I have a set of 12 values that I get from using a formula @Expected 10% New. Now I want to store these values in a array and reference each of them separately in my details section. This is what I have done so far.
 
In my formula I have the following
 
WhilePrintingrecords;
global numbervar Array inv1Array;
redim preserve inv1Array [ubound(inv1Array)+1];
inv1Array [ubound(inv1Array)+1] := {@Expected 10% New};
 
In another formula I have the following to reference the first value in the array and I place this in the details section.
 
WhilePrintingrecords;
global numbervar Array inv1Array;
inv1array[1]
 
but I get an error saying "A subscript must be between 1 and the size of the array"
 
What am I doing wrong. Please help!
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Apr 2010 at 3:35am
when you redim, you set the amount to say 1, but when you are assigning, you are now looking at 2...just use the ubound(inv1Array) in the assignment.
 
HTH
IP IP Logged
radibhatla
Newbie
Newbie


Joined: 01 Mar 2010
Location: United States
Online Status: Offline
Posts: 6
Quote radibhatla Replybullet Posted: 22 Apr 2010 at 5:18am
Hi,
 
Thanks for your reply. But I am not sure how to modiy the formula still. When you aid use the ubound(inv1Array) in the assignment did you mean that I should not use redim preserve at all?
 
Thanks for your time.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 22 Apr 2010 at 8:59am
WhilePrintingrecords;
global numbervar Array inv1Array;
redim preserve inv1Array [ubound(inv1Array)+1];
inv1Array [ubound(inv1Array)] := {@Expected 10% New};
 
only change made.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum