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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport and formulas

Status
Not open for further replies.

GPowers

MIS
Mar 27, 2003
8
US
I am running Crystal Reports 8.5. I have a main report and inserted two subreports. I need to know how to calculate the difference between the totals in the three reports EX.

Fac RPT1 SR1 SR2 Total %
Not Comp.
Comp.

AAAA 245 128 156 xxxx yyyy
BBBB 846 451 536 xxxx yyyy

In this example rpt1 is the main report, sr1 is the first subreport, sr2 is the second subreport. The subreports are linked to the main report by the Facility or fac in the group footer. Where xxxx I need to calculate the difference between rpt1 and sr2. Where yyyyy I need to determine the percentage complete.

Any help would be appreciated.
 
You can pass values between main reports and subreports, but the order that they fire is critical, Note that slightly shifting the subreports down will cause them to fire last.

So in the main report you might use:

whileprintingrecords;
shared numbervar PassNum := sum(table.field});

Then in the subreport you can use that value:

whileprintingrecords;
shared numbervar PassNum;
Sum({table.field}) / Passnum

Obviously not your exact solution, but hopefully it demonstrates how to share variables between reports well enough for you to work it out.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top