Doubling of page total

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report. There is a column of amounts. I keep a running total and
print it at the end. When I run the report, the display comes up exactly as
it should, but when I print it, the value doubles.

Here is the code I've used:

Option Compare Database
Dim total_claim As Currency

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
total_claim = total_claim + Me.Amount
Me.Total = total_claim
End Sub

What have I done wrong? How can I fix it? Thanx.

L
 
I have a report. There is a column of amounts. I keep a running total and
print it at the end. When I run the report, the display comes up exactly as
it should, but when I print it, the value doubles.

Here is the code I've used:

Option Compare Database
Dim total_claim As Currency

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
total_claim = total_claim + Me.Amount
Me.Total = total_claim
End Sub

What have I done wrong? How can I fix it? Thanx.

L

It's always best to do calculations using controls directly in the
report, not using code in a section's Print or Format event.
If this is what you must do, then code the Report Header Format event:
What is [Total]? An unbound control?

total_claim = 0
Me![total] = 0
 
Louie Warren said:
I have a report. There is a column of amounts. I keep a running total and
print it at the end. When I run the report, the display comes up exactly as
it should, but when I print it, the value doubles.

Here is the code I've used:

Option Compare Database
Dim total_claim As Currency

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
total_claim = total_claim + Me.Amount
Me.Total = total_claim
End Sub

What have I done wrong? How can I fix it? Thanx.


Find another way to calculate the total. Using event
procedure code to calculate a value across multiple records
just will not work because, for many reasons, Access may
process a section multiple times in a relatively random
order.

The standard way to total a field in the report's record
source table/query is to use a footer text box with an
expression like:
=Sum(Amount)

If Amount is not a field in the record source table/query,
then use a text box in the detail section with its
RunningSum property set to Over All or Over Group.
 
The standard way to total a field in the report's record
source table/query is to use a footer text box with an
expression like:
=Sum(Amount)

If Amount is not a field in the record source table/query,
then use a text box in the detail section with its
RunningSum property set to Over All or Over Group.

Obviously, I don't understand... I went to the Data tab, for the Text Box's
Properties, and changed control source to =Sum(Amount) and the report comes
up with #Error. I went into expression builder and created an expression
directly identifying the query and field (Amount is in the query... I have
numerous line items based on a date and I want to total the cost at the
bottom of the page. Sorry to be so dense.
 
Louie said:
Obviously, I don't understand... I went to the Data tab, for the Text Box's
Properties, and changed control source to =Sum(Amount) and the report comes
up with #Error. I went into expression builder and created an expression
directly identifying the query and field (Amount is in the query... I have
numerous line items based on a date and I want to total the cost at the
bottom of the page.


You probably have the total text box in the report's Page
Footer section. The aggregate functions only work in the
Report and Group Header/Footer sections.

Given that distinction, you need to provide more details
about what you need to accomplish and in what situations
before anyone can attempt to describe a way to meet your
needs.
 
--
Help spread the word!
http:.//home.earthlink.net/~es336td/stolen.html


Marshall Barton said:
You probably have the total text box in the report's Page
Footer section. The aggregate functions only work in the
Report and Group Header/Footer sections.

You are correct...
Given that distinction, you need to provide more details
about what you need to accomplish and in what situations
before anyone can attempt to describe a way to meet your
needs.

It's real simple. I have a flex spending account. I record all my receipts
and then when I want to make a claim, I run the report. It has all the line
items (receipts) listed and in the old Excel spreadsheet, I would just put a
SUM(XXX:XXX) at the end and it would be done. All I want is for the report
to work like it did in the original question, and the number displayed to
remain static when printed. Does that explain it or am I missing something?
Thanx!

L

 
Louie said:
You are correct...


It's real simple. I have a flex spending account. I record all my receipts
and then when I want to make a claim, I run the report. It has all the line
items (receipts) listed and in the old Excel spreadsheet, I would just put a
SUM(XXX:XXX) at the end and it would be done. All I want is for the report
to work like it did in the original question, and the number displayed to
remain static when printed. Does that explain it or am I missing something?


So you do not really need it at the bottom of the page, just
after the last detail. Right?

If so, then move the text box to the Report Footer section
and it should do what you want.
 
Back
Top