Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass array from one subreport to another

Status
Not open for further replies.

1chicken

Programmer
Jun 11, 2003
20
US
I need to set up an array that captures each group 1 field and passes it to a subreport for comparison. Ex.

Main Report
Schedules
Jane
Jack
John

Subreport 1
Employees
G1=Jane
John
Jack

Subreport 2
Terminated Employees
John
Jane

I want to highlight John and Jane's names in subreport 1 to make it more obvious on the first subreport that they appear on the second.
 
Seems odd that subreports would be required, but you can pass variables to anf from subreports.

In the group header of the main report place a formula containing something like:

whileprintingrecords;
stringvar array Employees;
Employees := Employees+{table.Employees}

In the report footer you could then palce a subreport which has a formula with something like:

whileprintingrecords;
stringvar array Employees;
join(Employees,", ")

To display them.

You could also suppress rows based on this using something like:

whileprintingrecords;
stringvar array Employees;
{table.field} in Employees

If you just want to limit the rows in the sub to match the rows in the main, just use the same record selection criteria.

Rather than describing how you intend to implement a report, consider describing your environment, table layout, example data, and expected output, someone may have a simpler way of address it.

-k
 
CR9 is telling me that the result of a formula can not be an array when trying this...
 
When trying what?

You might want to share what you tried when describing an error...

The first thing I offered should have an additional semi-colon:

whileprintingrecords;
stringvar array Employees;
Employees := Employees+{table.Employees};

-k
 
I tried to create a formula called var1 with the following data and received the aforementioned error:

whileprintingrecords;
stringvar array Employees;
Employees := Employees+{MONTHLY_PRODUCT_MONITOR.OFFER_CODE_DESC};
 
Seems to work here, are you sure that you included the last ; ?

Try this:

whileprintingrecords;
stringvar array Employees;
Employees := Employees+{MONTHLY_PRODUCT_MONITOR.OFFER_CODE_DESC};
1

This should not be returning an array (nor should it have before), so at least this sidesteps it for now.

-k
 
I think declaring it as an array is causing the error, and the array declaration isn't really necessary, is it, SV? I think this would work:

whileprintingrecords;
stringvar Employees;
Employees := Employees+{MONTHLY_PRODUCT_MONITOR.OFFER_CODE_DESC};

Then display with:
whileprintingrecords;
stringvar Employees;

Although it looks like employee names are no longer being collected, but, instead, code descriptions...

-LB
 
Hmm, I screwed this up, sorry.

To pass an array, then use something like:

whileprintingrecords;
stringvar array Employees;
Numbervar arrayindex:= 1
Employees[arrayindex] := {table.Employees};

In the Group Footer place something like:
whileprintingrecords;
stringvar array Employees;
Numbervar arrayindex:= arrayindex+1;

Now you have an array.

In the report footer you could then place a subreport which has a formula with something like:

whileprintingrecords;
stringvar array Employees;
join(Employees,", ")

To display them.

You could also suppress rows based on this using something like:

whileprintingrecords;
stringvar array Employees;
{table.field} in Employees

Again, I don't think that they need an array at all, but since requirements weren't stated, nor the environment, I adressed the question (probably just wasting time).

It should probably just use the exact same criteria as the main report, gorup by the employee, and display the data in the group footer.

-k
 
LB: I think that the intent was to limit rows in the subreports, not display data from the main report.

-k
 
OK, Maybe I can start over. I'm not very good at asking for help...

I have two subreports embedded in a main report. Each pulls from a separate data source but has comparable records. I want to compare the values in the second subreport to values in the first, highlighting records when they match.

Maybe this is a more understandable explanation.
 
To have matching names highlighted in the first subreport, I think you will need to add a "dummy copy" of the second subreport to a section preceding the first subreport. (This is similar to the dummy subreport you would create if you wanted to conditionally suppress a subreport - see numerous other posts on that topic for details on how to do this)

Use this dummy subreport to create the shared array (as synapsevampire has outlined), then in the first subreport, use the shared array to apply conditional formatting to the fields that match.

e.g. if you want to have the matching employees names in bold, then use the following as your Format Font Style conditional formatting formula....

shared stringvar array Employees;
if {TABLE.EmployeeName} in Employees then CrBold
else CrRegular

Hope this helps...

Jason Street.

-----------
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top