problem with counter incrementing during printing

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

Guest

I have a counter on an Access report that increments when a particular
condition is true at the detail level (using vb code in Detail_Print). I
initialize the counter in Report_Open subroutine. When viewing the report in
preview mode, everything works well with the counter starting at 1 and
incrementing from there. The problem I'm having is that if the user prints
from the report preview screen, the counter on the hard copy report does not
get reinitialized so the hard copy counter starts where the print preview
counter ended. Is there an alternative ON..... subroutine I need to call?
Thanks!
 
AC said:
I have a counter on an Access report that increments when a particular
condition is true at the detail level (using vb code in Detail_Print). I
initialize the counter in Report_Open subroutine. When viewing the report in
preview mode, everything works well with the counter starting at 1 and
incrementing from there. The problem I'm having is that if the user prints
from the report preview screen, the counter on the hard copy report does not
get reinitialized so the hard copy counter starts where the print preview
counter ended. Is there an alternative ON..... subroutine I need to call?


No, there isn't. What you're seeing is just the tip of the
list of problems when you try to use code in event
procedures to calculate a value across multiple data
records. The reason this can't work reliably is that there
are many situations (previewing out of order, various
settings for KeepTogether and CanGrow/CanShrink, etc) where
the events are not triggered sequentially record by record.

Sometimes you can do the counting in the report's record
source query, but it's often easier to use a text box on the
report. Set the text box's RunningSum property to Over All
or Over Group as appropriate to your needs. The text box's
expression would just be like:
=IIf(<your condition>, 1, 0)
 
Back
Top