Link to home
Start Free TrialLog in
Avatar of viola123
viola123

asked on

Error: an array's dimension must be an integer between 1 and 1000

hi, all
i have an error when i run my crystal report:
an array's dimension must be an integer between 1 and 1000
it seems the "Redim Preserve" causing the error.
the code is below:
Shared UnrealisedReducedCostBases() as String
 
Dim key, value, i
 
key = {@SecurityExchange}
value = CStr(Sum({IPSUnrealisedCapitalGainGetByAccount1.ReducedCostBase}, {@SecurityExchange}))
 
i = UBound(UnrealisedReducedCostBases) + 1
Redim Preserve UnrealisedReducedCostBases(i)
 
UnrealisedReducedCostBases(i) = key & "," & value
 
formula = key

Open in new window

Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you saying the error message is incorrect?
Could there be more than 1000 entries?
Avatar of viola123
viola123

ASKER

hi, i mean i have this error, how to solve it.
if there is more than 1000 records returned, the line:
Redim Preserve UnrealisedReducedCostBases(i)
pops up the above error. how to solve it?

thanks
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the problem is i am total new to this crystal reports. i dont even understand what is running total,
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks a lot
i will have a look at if i can use multiple arrays.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree.  

Since you are new to Crystal you may not fully understand how Crystal processes the data.  In general arrays are not needed for processing the data.

If you tell us why you need the array or what you are trying to do with it then perhaps we can help.

mlmcc
hi guys,
thanks for all your reply, i pass this problem to another guy who is expect on CR.

so thanks heaps

viola
You're welcome.

 James
Easiest way to trap for null data in an array is to not attempt to print it when your report is generating

For Example
you want to Create an array of addresses

first determine the data that will be in the array

    {Command.PartyName} & Chr(010) &
    iif({Command.PartyAddress1} <> "", {Command.PartyAddress1} & Chr(010), "") &
        iif({Command.PartyAddress2} <> "", {Command.PartyAddress2} & Chr(010), "") & 
        iif({Command.PartyCity} <> "", {Command.PartyCity} , "") &
        iif({Command.PartyState} <> "", {Command.PartyState} & " ", "") & 
        iif({Command.PartyZip} <> "", {Command.PartyZip}, "")


Then Set The Array by adding the AddressArraySet to the Group on your page where the data will display

StringVar Array AddressArry;

    IF NOT ({@Address} IN AddressArry) THEN
        (
            Redim Preserve AddressArry[UBound(AddressArry) +1];
            AddressArry[UBound(AddressArry)]:= {@Address};
        );
    "";

Then finally add the array to where you want it to Display on your form

WhilePrintingRecords;
numberVar n;
StringVar Array AddressArry;
StringVar Array Output;
numberVar cnt;
cnt := UBound(AddressArry);
if(cnt >= 1) then
(
Redim Output[UBound(AddressArry)];
For n := 1 to UBound(AddressArry)
    do(output[n] := AddressArry[n];);
Join(Output, Chr(13))
);

The If(cnt) section is where you are verifying the array has data in it, and if it
does not then it will skip the Display portion and move on eliminating the
error message
You do realize that that question is over 3.5 years old, right?

 James
That answer from 2012 actually helped me in 2018! Thanks!