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

Totaling sub report fields in the main report

Status
Not open for further replies.

jwv333

Technical User
Apr 13, 2006
2
US
I get "error" when I use the expression builder to total sub report fields in a report. I don't know how to get the main report to recognize fields from the sub reports.
 
Create an Unbound textbox on your main form. Then in the Control Source Option on the property sheet type something like this:
=[Forms]![Orders Entry Form]![Order Details Entry Form].[Form]![Quantity]+[Forms]![Orders Entry Form]![Order Details Entry Form].[Form]![Unit Price]

In general, to reference a subform control
[Forms]![MainFormName]![SubFormName].[Form]![ControlName]
 
jwv333,
You didn't provide the expression you used that got the error, the name of the subreport object, the name of the control on the subreport that you want to reference from the main report,...



Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
jwv333
There's an additional issue to be checked. If it's possible for a subreport total to be Null, you need to check for data using the HasData property.

Tom
 
In an unbound textbox on the main report here is my expression:
=[PO Qtr Payment]+rpt_employee_report_sales.Report![Qtr Payment]+rpt_employee_report_shvi.Report![Qtr Payment]

none of the values from the sub reports are null, all of the objects that are being sub totaled are from other reports that are built from queries.
 
First, are all the subreports and your text box in the same section of the main report? Second, if it is possible that a subreport might not return any records, consider using:
Code:
=[PO Qtr Payment]+IIf(rpt_employee_report_sales.Report.Hasdata, rpt_employee_report_sales.Report![Qtr Payment],0)+IIf(rpt_employee_report_shvi.Report.Hasdata, rpt_employee_report_shvi.Report![Qtr Payment],0)


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
=[PO Qtr Payment]+[Forms]![Report]![rpt_employee_report_sales].Form![Qtr Payment]+[Forms]![Report]![rpt_employee_report_shvi]!.Form![Qtr Payment]

If I figured out what you typed,
Report is your main form's name.
rpt_employee_report_sales is subform
rpt_employee_report_shvi is subform
[PO Qtr Payment] is control on main form
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top