Totals In Report Footer

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

Guest

Hi,

I have a report that totals the number of members that payed their dues,
that works in Access 2002. However, when I try to run the report in Access
2003 it doesn't print the total, it does print the rest of the information.
What am I doing wrong in Access 2003?
 
This is not typical of anything I have heard of. What have you tried during
your trouble-shooting?
 
Hi,

Well, I used "debug.print" and the variable in the module does wind up with
the right number (79).

"txtReportTotal" (see below) is the control source for the text box in the
report footer. It is declared as a Public variable in the General section of
the module. I also checked the references and they seem to be the same as
the 2002 references except using the Object 11.0 library instead of the
Object 10 library.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

txtReportTotal = txtReportTotal + 1
Debug.Print txtReportTotal

End Sub
 
cmckeever said:
Well, I used "debug.print" and the variable in the module does wind up with
the right number (79).

"txtReportTotal" (see below) is the control source for the text box in the
report footer. It is declared as a Public variable in the General section of
the module. I also checked the references and they seem to be the same as
the 2002 references except using the Object 11.0 library instead of the
Object 10 library.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

txtReportTotal = txtReportTotal + 1
Debug.Print txtReportTotal

End Sub


We just had someone else point this out a few days ago. THe
issue is that a Public variable in a class module (your
report's module) is a property of the class. In AXP, this
worked, but in A2003 it doesn't. I think that is good
enough to answer your question, but the real issue here is
that regardless of how long your code has worked, it was
never guaranteed that it would continue to work.

The real problem is that you can not use code in event
procedures to calculate any multi record value. The events
can be executed as many times and in whatever order Access
requires to present the report.

You should either use an aggregate function (Count, Sum,
etc) in a group and/or report header/footer section or use a
text box with its RunningSum property set appropriately.

Based on your posted code, I think the footer text box could
just use the expression:
=Count(*)
 
Your first question suggested nothing about code. I don't understand:
1) why you are using code when report totals are usually as simple as a text
box with a control source like:
=Sum(NumericField)
or since you seem to be counting, not summing
=Count(*)
or
=Sum(1)

2) why you would not provide the information about using code in your first
message...
 
Dan,

In answer to your question, it's probably because I don't know what I'm
doing. I just looked up the code in some book and struggled to get it to
work.

Sorry about that. Thanks for taking the time to reply.
 
I can't imagine a book making a suggestion like unless it was taken out of
context.
 
Duane said:
I can't imagine a book making a suggestion like unless it was taken out of
context.


Surely you can imagine that Duane ;-)

Proof of Existence:
Tthere are several KB articles that "recommend" using a
similar technique (although not for something as simple as a
counter).

Conclusion:
As there are hack programmers, there are hack authors.
 
Back
Top