Subreports and totals

W

Wvanexe

I have created a report with two subreports. I need to be
able to have a total of a field on the subreports.

Ex.
Main form
Part Number, Qty, Hours
Subform 1
Downtime, minutes
Subform 2
Downtime, minutes

Report when run

Item 1. Part Number, Qty, Hours
Subform 1 Subform 2
Break, 1 No records
Meal, 5
Subtotal 6 Subtotal 0

Item 2. Part Number, Qty, Hours
Subform 1 Subform 2
No records Equip, 5
Parts, 6
Subtotal 0 Subtotal 11

Item 3. Part Number, Qty, Hours
Subform 1 Subform 2
No records No records
Subtotal 0 Subtotal 0

Main Form Total 6 Total 11

I have placed a field on each subform to total the
minutes. I need to add up the subtotals to a total field
on the main form. I get an #error.

The problem is that on the main form there will always be
data, the subforms may have data or not. 1 record or more
records could be returned for each subform.

Any help would be appreciated.
 
D

Duane Hookom

You can use the HasData property of the subReports.
=IIf(subReport1.HasData,subReport1.Report.txtTotal,0)
Use similar expressions as needed in your main report.
 
W

Wvanexe

Thank you Duane.

The HasData works but my problem is that I need to get a
grand total for a group and all I get back is 0's.

If item 1 is subtotal 1 my grand total would be 1
If item 1 is subtotal 1 and item 2 is subtotal 0 my grand
total would be 0, I need it to be 1.

This is giving me a headache.

Wvanexe
 
D

Duane Hookom

I assume you have total text boxes on the subreports. You can use the
expression I provided to grab totals for your main report. If you then add
these two totals together, you will have the sum.
 

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

Top