cancel
Showing results for 
Search instead for 
Did you mean: 

How to use array function?

Former Member
0 Kudos

I want to create a array with the data are in the table (one or more than one field).

By using function makearray or array, it can create the array with one record

e.g.

Local stringvar Array x := MakeArray ({CASES.ASSIGNTO});

ubound(x);

the result will be 1, means only one record is in the Array x.

Actually, I want to get all records of the field CASES.ASSIGNTO.

Accepted Solutions (1)

Accepted Solutions (1)

former_member260594
Active Contributor
0 Kudos

Hello Kent,

You can't just assign all field values to an array, the formula needs to process each record in the details section and assign the record to the array. Here is a sample formula that would assign all countries to an array;

WhilePrintingRecords;

stringvar array t;

numbervar x;

x:= x + 1;

redim preserve t[x];

t[x]:= {Customer.Country};

t[x]

If you need the completed array available in the main report before the Report Footer then you would need to use a subreport in the Report Header to generate the array and then using a shared variable pass it back to the main report.

Also note that an array is limited to 1000 elements so if there is a possibility of the number of records exceeding 1000 you will need to create more than 1 array and depending on the value of the counter assign the records greater than 1000 to the second array

Former Member
0 Kudos

Thank your reply.

it means that no simple function to create a array contain table data?

because i want to use array for calculate to reduce the running time, actually, i am not willing to looping record in sub-report

former_member260594
Active Contributor
0 Kudos

An array can only be built record by record within Crystal Reports.

If you could explain exactly why you need an array for your calculation there may be another way of doing the calculation

Former Member
0 Kudos

It is because I need to put those data into a subreport which placed on page header. Becuase calculation is complicated, it must work in a subreport (using the feature record looping).

Acutally, I want the subreport data (in the page header) is same as main report data but CR have no function to duplicate data into subreport. Thus i need to check all contents of fields and passing them as a filter (by selection expert) into subreport.

regards

Answers (0)