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

Who is Participating?
As has already been said, CR limits arrays to 1000 elements.

 Why are you using an array?  Do you really need to save all of those individual totals?

 It sounds like you have this formula in the detail section.  If so, that's probably a mistake.

 You're saving the total of ReducedCostBase for the {@SecurityExchange} group.  That presumably means that you only need to save the total once for each group.  If the formula is in a detail section, it's going to save the total with every record, saving each group total multiple times.  Put the formula in the {@SecurityExchange} group footer instead.  Then you will only have a problem if you have more than 1000 {@SecurityExchange} groups on one report.

Are you saying the error message is incorrect?
Could there be more than 1000 entries?
viola123Author Commented:
hi, i mean i have this error, how to solve it.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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

Crystal Reports does not handle arrays of more than 1000 elements.
So there is no way round that.

You have to look for a different way to create your report.

Can you use running totals, or subreports to limit what you need to hold as an array?
viola123Author Commented:
the problem is i am total new to this crystal reports. i dont even understand what is running total,
You can look at these features in Help but I'm only using them as examples of how you might approach the report.  I have no idea whether they would provide a solution in your case.
You can look at having multiple arrays, combining multiple values into one array 'cell' but again I can't tell you that these will do what you require in your report.
There is no standard solution to this issue.
viola123Author Commented:
thanks a lot
i will have a look at if i can use multiple arrays.
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.

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

so thanks heaps

You're welcome.

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

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?

Cassandra L FriesonProgrammer SeniorCommented:
That answer from 2012 actually helped me in 2018! Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.