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

Access 2002: Sum of fields on two subreports?

Status
Not open for further replies.

TheElephantMan

Programmer
Jun 18, 2004
42
US
Hello, all.

I have two reports with identical structures but different source queries that I have merged together as subreports on one main report. On each of the subreports is a grand total field, and I would like to add a field to the main report that shows the sum of those two grand totals to make a grand grand total.

I cannot quite figure out how to make this happen. Help would be most appreciated.

Thanks in advance,
TEM
 
Make sure that each subreport has a text box with the total from the subreport. Then add a text box to the main report with an expression like:
=subrpt1.Report.txtTotal + subrpt2.Report.txtTotal
This should work for all reports except where one of the subreports might not return any records. Is this possible?

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
use this formal it will help when no reords are in on of the reports.

Code:
= nz(subrpt1.Report.txtTotal,0) + nz(subrpt2.Report.txtTotal,0)

the nz funciton will pass back 0 if the totals are null.

Brought to you By Nedaineum
The Portal to Geek-tum
 
Thanks for the suggestion, but I already tried that; when I utilize the above method, the field comes up on the report as "#Name?".

Is there something we're missing?

Thanks,
TEM
 
TEM and bitmite,
Nz() will not provide any functionality if one or both of the subreports return no records. You would need to use:
Code:
= IIf(subrpt1.Report.HasData,subrpt1.Report.txtTotal,0) + IIf(subrpt2.Report.HasData,subrpt2.Report.txtTotal,0)

TEM,
Make sure the name of the control is not also the name of a field. Also, the text box should be in the same section of the report as the subreports.



Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top