Sub-Report Totalling

  • Thread starter Thread starter Howard
  • Start date Start date
H

Howard

I was given great advise to achieve the results I needed
by dragging a sub-report into a report ... didn't know I
could do that ... worked great! Now I'm trying to grand
total a sub-report field into a report footer field in the
main report. I used the sum function but it doesn't seem
to recognize the field in the sub-report. Is that because
the main report is not bound to the same query as the sub-
report? How can I overcome this? Please let me know.
Thanks!
-Howard
 
Howard said:
I was given great advise to achieve the results I needed
by dragging a sub-report into a report ... didn't know I
could do that ... worked great! Now I'm trying to grand
total a sub-report field into a report footer field in the
main report. I used the sum function but it doesn't seem
to recognize the field in the sub-report. Is that because
the main report is not bound to the same query as the sub-
report?

You're right. Sum only operates on fields in the record
source table/query.

A main report can retrieve values from its subreports'
controls in the subreport's header/footer sections. The
syntax to do this in a main report text box named
txtRunTotal is:
=subreportcontrol.Report.textbox
or if there's a chance that there may not be any records in
an instance of the subreport:
=IIf(subreportcontrol.Report.HasData,
subreportcontrol.Report.textbox, 0)

To total those values, set the txtRunTotal text box's
RunningSum property to Over All. Then the main report's
footer's text box can display the total using the
expression:
=txtRunTotal
 
Thanks ... I'll give it a try!
-----Original Message-----


You're right. Sum only operates on fields in the record
source table/query.

A main report can retrieve values from its subreports'
controls in the subreport's header/footer sections. The
syntax to do this in a main report text box named
txtRunTotal is:
=subreportcontrol.Report.textbox
or if there's a chance that there may not be any records in
an instance of the subreport:
=IIf(subreportcontrol.Report.HasData,
subreportcontrol.Report.textbox, 0)

To total those values, set the txtRunTotal text box's
RunningSum property to Over All. Then the main report's
footer's text box can display the total using the
expression:
=txtRunTotal
 
Back
Top