Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Number of Report Pages

Status
Not open for further replies.

Rohdem

Programmer
Sep 20, 2000
553
US
Is there any way I can use VB to count the number of pages in a report? I would like to message box this to the user before they print. I know that I could open the report in design view and have the user click the arrow to go to the end of report, but the report is between 100 and 400 pages long with a lot of info on each page, so it can take quite a few minutes for it to display the last page.

Mike Rohde
rohdem@marshallengines.com
 
I dont know of a way of counting the pages but what you could do is use a Dcount to count the number of records your report is likely to return.
This way you could divide the total number of records normaly displayed on a page by the returned value of Dcount.
This way, at least you would be able to give the user an approximate number of pages for the report and let them decide whether or not they want to print it.

Eradic8or.
 
I have the answer for you. Paste this code into the Page event of your report.

Let me know if you have trouble making it work.


Dim intTotalPages As Integer, strMsg As String
intTotalPages = Me.Pages
strMsg = "This report contains " & intTotalPages & " pages."
MsgBox strMsg

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top