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

Using Total of a Subreport to do a calculation in the main report

Status
Not open for further replies.

khan82

Technical User
Feb 23, 2012
57
CA
I have a sub report that shows $ amount charged to a particular tenant for a defined period.

I need that number to be inserted into the main report so i can do a calculation.

How can i make the sum in sub report group footer global?
 
Make it part of a formula and assign to a shared variable. Of course you will need another formula in the main report with the same shared variable name to be able to manipulate it as needed.
 
how do i create a shared variable?
 
In a formula use the syntax

shared currencyvar myvar;

I am assuming that the variable would be a currency amount. You will need to assign the variable with a value (from a field?). Also be aware that the variable value will be set in the main report in a section after where the sub report resides.

 
so i created the following formula "Billed" in the sub report and placed it in the group footer.

WhilePrintingRecords;
Shared NumberVar Billed;

Billed := Sum({PMT_CURRENT__TRANSACTION.Charge_Amount});

Then i went to the main report and created another formula called billed, in which i am using the Billed amount form the sub-report to calculate the difference a tenant would owe after subtracting their share.

WhilePrintingRecords;
Shared Numbervar Billed;
- Billed + {@TenantShareTotal}

problem is that for some reason i am getting two pages per tenant. First one shows the incorrect calculation and the second shows correct ones.

This is what the report looks like
Report_zpsebc4a13b.jpg
 
The formulas look correct. Why you are getting two pages per tenant I do not know. That would be how you are grouping and/or showing the details. Plus the DB linking in the main report. This may need to be a new thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top