Calculating totals from subreports

G

Guest

I have created a report with multiple subreports. I need to calculate totals
from the sub reports and display the total in a text box on the main report.
Each sub report is based on a different query. Depending on the criteria
(Customer), occasionally some of the queries on which the sub reports are
based contain no records, because the customer will not have any records in
that query for that period. How can I perfom these calculations without
getting an error?
 
D

Duane Hookom

Use a control source on your main report like:
=IIf(subreportA.Report.HasData, subreportA.Report!txtTotal,0)
Of course, this will vary based on your subreport and control names.
 
G

Guest

I tried to use the following expression as the conrtol source for txtTotal:

=IIf([srptA].[Report].[HasData],[srptA].Report!txtInvBal,0)+([srptB.[Report].[HasData,[srptB].Report!txtInvBal,0)

srptB has no records. Rather than showing the value of txtInvBal, txtTotal
has no value at all. Am I using the correct syntax?
 
D

Duane Hookom

You have eight "[" and only six "]".

--
Duane Hookom
MS Access MVP

JoeA2006 said:
I tried to use the following expression as the conrtol source for txtTotal:

=IIf([srptA].[Report].[HasData],[srptA].Report!txtInvBal,0)+([srptB.[Report].[HasData,[srptB].Report!txtInvBal,0)

srptB has no records. Rather than showing the value of txtInvBal, txtTotal
has no value at all. Am I using the correct syntax?

Duane Hookom said:
Use a control source on your main report like:
=IIf(subreportA.Report.HasData, subreportA.Report!txtTotal,0)
Of course, this will vary based on your subreport and control names.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top