Determine the Number of Pages in a Report

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

Guest

How do I use VBA to determine the number of pages in an Access 2000 Report?

Thanks!
-Joe W.
 
Joe W. said:
How do I use VBA to determine the number of pages
in an Access 2000 Report?


If you have a text box that uses Pages somewhere in the
report, then a VBA procedure can refer to it using Me.Pages

For example, you might do something like this in a section's
Format event:
If Me.Page = Me.Pages Then
' do something on last page
End If
 
Open reports have a Pages property, but it's a strange beast.

Trying to read:
Reports("Report1").Pages
from another routine will not be productive.

You could use the Print event of the Report_Footer section to write the
value of Pages to a public numeric variable, and then read the value in your
code, but there are several pitfalls with that approach, e.g.:
- It may not have run to the end yet.

- If there are events that mess with the runtime properties MoveLayout,
MoveRecord etc, the Pages property may contain the wrong value. In fact you
can end up with Page being 9 and Pages being 8.

- It is possible to programmatically reset the Pages property, so it may not
be correct.
 
Back
Top