Main-sub total

  • Thread starter Thread starter rob p
  • Start date Start date
R

rob p

I have some main-subreport ques. Main has a variable amount of detail
records each ending with an amount in the last field. I want to list all of
these and then show the total of the amount field.

I then want a subreport to pick up where the main quits. It will have a
variable amount of detail records too. Also an amount in the last field.
Totalled for subreport.

Grand total is total of the amount field for main and subreport.

Is there a sample report that does this? I am having a problem figuring out
where to insert the sub and how to total between main and sub.

thanks.
 
1. Open the subreport (from the database window) in design view.

2. If you do not see a Report Footer section, choose "Report Header/Footer"
from the View menu.

3. In the Report Footer section, place a text box. Right-click it and choose
Properties. Set these properties:
Name txtTotAmount
Control Source =Sum([Amount])
Format Currency

4. Save and close the subreport.

5. Open the main report in design view.

6. Below the subreport, add a text box with this Control Source:
=IIf([Sub1].[Report].[HasData], Nz([Sub1].[Report].[txtTotAmount], 0), 0)

Replace "Sub1" in that expression with the name of your subreport control.

This brings the total from the subreport back onto the main report. If there
happen to be no records in the subreport, attempting to read to total of the
non-existent records produces an error. That's why we test the HasData
property of the report in the subreport control.

You can now add in the total from the main report as well.
 
Back
Top