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

Summing values from values in a subreport.

Status
Not open for further replies.

fiel

Programmer
Jun 3, 2007
96
US
I have a report called rpAllTotal that list subtotals for a company in the main body of my report. I have 3 seperate subreports within it listing side costs such as travel, hotel, and food named: rpTravel, rpHotel, and rpFood. In these three subreports is a textbox that holds the total cost of each side expense. in my main report I'm trying to take all the values from the main body and the three subreports and sum them all together, I put the following in the control source for a textbox I created.

=[MainTotal]+[rpTravel.Subtotal]+[rpHotel.Subtotal]+[rpFood.Subtotal]

The problem is that I am not able to even preview the report, I get an error saying "The Microsoft Jet Database Engine does not recognize '[rpTrave].[Subtotal]' as a valid field name or expression". I'm pretty sure the error is in my syntax for the subreports; would anyone happen to know that proper syntax?
 
First, will all subreports always have records/data to display? If so, try:
=[MainTotal]+[rpTravel].Report.[Subtotal]+[rpHotel].Report.[Subtotal]+[rpFood].Report.[Subtotal]

If there is a possibility that any one of the subreports might not contain related records then you must use something like:
=[MainTotal]+IIf([rpTravel].Report.HasData,[rpTravel].Report.[Subtotal],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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top