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

Unable To Reference Subreport Total

Status
Not open for further replies.

rookery

Programmer
Apr 4, 2002
384
GB
I have a report that details customers and the items they have bought. The "Detail" section of the main report houses a subreport which displays all the items for that particular customers order. The customer may have more than one order but only one invoice is displayed at a time.

In this subreport within the "Report Footer" section there is a text box whose control source is the sum of all the totals within the subreport.

On the main report in the "Page Footer" section I'm trying to reference this invisible total but all I'm getting is the total for the next group of records instead.

Yet if I put this same text box into the "Detail" section of the main report i.e. where the subreport is, it works fine and displays the expected total.

It's only when it's in the "Page Footer" section that it seems to not work. Even putting it in "Page Header" works but it looks stupid.

I hope I've explained this well. Can anyone help - its driving me nuts!!
 
...the plot thickens. The invisible text box on the Subreport Report Footer displays a different total to what you get if you reference it in code.

That is I wrote some code in the On_Format event and then put a break in and checked the Debug window for the value of that textbox and it wasn't the same.

Very weird. Anyone help?????
 
Make the text box visible while you test and design. Hide it when you are happy with the results.

Keep your text box in the detail section that references the subreport total. Name the text box "txtTotFromSubRpt".

Add a text box to the Page Footer and set its control source to:
=txtTotFromSubRpt

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]
 
Thanks Duane for your reply but I tried that already and it didnt work.

The answer in the end was to create a footer for the common parameter between the sub and main reports. In this case it was SalesID.

So I went to "Sorting and Grouping" selected the para set it to "Yes" on "Group Footer?" and placed the text box in there.

Result? It worked!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top