Report Footer Total Problem

  • Thread starter Thread starter Peter Marshall
  • Start date Start date
P

Peter Marshall

I have a rather complex report that includes 2 subreports. In the report
footer I have a textbox named txtGrandTotal, which I initialize to 0 in the
ReportHeader_Print event and increment in the DetailFooter_Print event with
the formula txtGrandTotal = txtLaborSubTotal + txtPartsSubTotal. When the
report is first PREVIEWED, the txtGrandTotal is correct, but when it is
PRINTED, it is exactly doubled regardless of how many DetailFooters the
report contains. What gives? How can I prevent this?

Peter Marshall
 
Peter said:
I have a rather complex report that includes 2 subreports. In the report
footer I have a textbox named txtGrandTotal, which I initialize to 0 in the
ReportHeader_Print event and increment in the DetailFooter_Print event with
the formula txtGrandTotal = txtLaborSubTotal + txtPartsSubTotal. When the
report is first PREVIEWED, the txtGrandTotal is correct, but when it is
PRINTED, it is exactly doubled regardless of how many DetailFooters the
report contains.


The Print (and Format) events can be executed
non-sequentially and any number of times. This means that
you can not use code in an event procedure to calculate a
result from multiple records. You'll have to find another
way.

One way is to use a text box named txtRunTotal with an
expression to calculate the value for a single record. You
can set the text box's RunningSum property to Over All to
calculate a running total. The text box in the report
footer can then display the grand total by simply using the
expression:
=txtRunTotal
 
I have a rather complex report that includes 2 subreports. In the report
footer I have a textbox named txtGrandTotal, which I initialize to 0 in the
ReportHeader_Print event and increment in the DetailFooter_Print event with
the formula txtGrandTotal = txtLaborSubTotal + txtPartsSubTotal. When the
report is first PREVIEWED, the txtGrandTotal is correct, but when it is
PRINTED, it is exactly doubled regardless of how many DetailFooters the
report contains. What gives? How can I prevent this?

Peter Marshall

Peter,
re: > I initialize to 0 in the ReportHeader_Print event <

Does it total properly if you reset the controls to 0 in the Report
Header's Format event instead of the Header's Print event?
 
Are we supposed to guess at your code and where txtLaborSubTotal and
txtPartsSubTotal are coming from? Are these text boxes visible and if so, do
they show the correct values? Do you have a reason for using code rather
than just expressions in control sources?
 
Well, Yes, Fred is brilliant. But be careful, as I said
earlier, this approach is unreliable. It may work now, but
some innocuous change somewhere down the road and it may not
provide the right total anymore.
 
Nice to hear that you've seen the light :-))

Years ago, I tore my hair out over this kind of thing, until
someone finally showed me the way, so I'm just passing it
on.
 
Back
Top