cancel
Showing results for 
Search instead for 
Did you mean: 

Assign array values to items in a sub report

Former Member
0 Kudos

Hi everyone,

I have a certain group in the main report. For each item in that group i want to store a corresponding value in the array.

In the sub report which is placed in the main report there may or may not be items in a group that match with items in the main report.

For example let items A,B and C are in the main report and have values.

If item B doesn't exist in the sub report,ignore the value at index 2 of the array and assign the value at index 3 to item C.

Is it possible to do that?

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Nebil,

Here's what you need to do :

1) In the existing formula on the Main Report, introduce another string array (alongside the number array that you already have) to store the group name at the same position. E.g:

WhilePrintingRecords;

shared stringvar array items;

shared numbervar array values;

numbervar x := x + 1;

redim preserve items[x] //this stores the group's name;

redim preserve values[x] //this stores the value for that particular group;

items[x] := {Group_Name};

values[x] := {@total} //your total formula;

"";

2) Inside the Subreport, create a formula with this code:

WhilePrintingRecords;

shared stringVar array items;

shared numbervar array values;

numbervar i;

If {Group_Name} IN items then

(

    for i := 1 to ubound(items) do

    (

        if items[i] = {Group_Name} then

        (

            numbervar v := values[i];

            exit for;

        );

    );

);

v;

Hope this helps.

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

It's working correctly. That's very helpful of you.

Thanks!

Answers (0)