Report Grand totals problem

T

ToniS

I have a report with a a few subreports. One sub report has the total fees
for an Exhibitor My problem is with in the Report Footer section the grand
totals display correctly but when the report is printed to a printer, the
grand total section is not correct. Below is what I have

More details on the problem: For example if the user is on the last page of
the report the total section was doubled. I then added the GrandTotalFees = 0
part and that fixed that problem. If the user is on the first page and
prints the report to a printer the total section on the last page is off by
the total amount that is on the first page (page 1 total fees is 150, Grand
total Should be 400 but prints 550).

When I click on the printer icon to print it goes through the Detail_Format
section agaain, I think I need to clear my grand totals but not sure which
event to do so..

Any ideas what I need to do?
Thanks
ToniS

Option Compare Database
Option Explicit

Public GrandTotalFees As Currency
Public GrandTotalPaid As Currency
Public GrandTotalBalance As Currency

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

' Calculate Grand Total line (end of report)
GrandTotalFees = GrandTotalFees + Nz([Report].[TxtSummaryTotalFees])
GrandTotalPaid = GrandTotalPaid + Nz([Report].[TxtSummaryTotalPaid])
GrandTotalBalance = GrandTotalBalance + Nz([Report].[TxtSummaryTotalBalance])

End Sub

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)

' Print Grand Total line (end of report)
Report_FeeTotals.TxtGrandTotalFees.Value = GrandTotalFees
Report_FeeTotals.TxtGrandTotalPaid.Value = GrandTotalPaid
Report_FeeTotals.TxtGrandTotalBalance.Value = GrandTotalBalance

GrandTotalFees = 0
GrandTotalPaid = 0
GrandTotalBalance = 0

End Sub
 
M

Marshall Barton

ToniS said:
I have a report with a a few subreports. One sub report has the total fees
for an Exhibitor My problem is with in the Report Footer section the grand
totals display correctly but when the report is printed to a printer, the
grand total section is not correct. Below is what I have

More details on the problem: For example if the user is on the last page of
the report the total section was doubled. I then added the GrandTotalFees = 0
part and that fixed that problem. If the user is on the first page and
prints the report to a printer the total section on the last page is off by
the total amount that is on the first page (page 1 total fees is 150, Grand
total Should be 400 but prints 550).

When I click on the printer icon to print it goes through the Detail_Format
section agaain, I think I need to clear my grand totals but not sure which
event to do so..
[snip a bunch of code that can not work]


You can not use code in event procedure to calculate a
result composed of values from more than the current record.
As you have seen, Access processes sections in whatever
order and however many times are necessary to format the
report. For example, think about what happens when a
KeepTogether section or group does not fit in its initial
location.

There are two features that can be used to calculate a grand
total. The easiest is to use a report (or group) footer
section text box with an expression like:
=Sum(<expression containing only record source fields>)
For example, an invoice total might be calculated by the
expression:
=Sum(Price * Quantity)

The other way is to use a running sum text box in the detail
section. You can calulate your grand total fees by adding
an invisible text box named txtRunTotalFees. Set its
control source expression to:
=TxtSummaryTotalFees
and its RunningSum property to Over All
Then the report footer text box can display the grand total
by using the expression:
=txtRunTotalFees
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top