Sub report Totals

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

Hi

I have a report, which also contains a subreport. Within the sub report
there is a quantity field. What I want to do is to display in the main
report, the sum of the quantity field from the sub report. I am not sure if
this can be done or how to do it. Can anyone help please

thanks
A
 
1. Open the subreport in design view.

2. If you do not see a Report Footer section at the bottom, click Report
Header/Footer on the View menu.

3. Add a text box to the Report Footer section, and set these properties:
Control Source =Sum([Quantity])
Format General Number
Name txtTotalQuantity
If you do now wish to see this total in your subreport, you can set the
Visible property of this text box to No, or set the Visible property of the
Report Footer section to No.

4. Save. Close.

5. Open the main report in design view. Add a text box below the subreport,
and set its Control Source to:
=[Sub1].[Report]![txtTotalQuantity]
Replace Sub1 with the name of your subreport control.

That works unless the subreport has no records. When that happens, there are
no text boxes in the subreport, so referring to it causes an error. Test the
subreport's HasData property. If the calculation results in Null, this can
also mess up other calcuations. Use Nz().

The end result will look something like this:
=IIf([Sub1].[Report]![HasData],
Nz([Sub1].[Report]![txtTotalQuantity],0), 0)
 
Back
Top