Count number of pages of a report

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

Guest

I have report that I need to have the number of pages counted and then the
number placed in a text box on a form. I am able to do this using the below
code in the report. The problem is first the report has be previewed or
printed before it performs this operation.

Can I get the number of pages of the report without having to print or
preview it and the user seeing this happen? i.e. It does not matter if the
report is opened or previewed as long as the user does not see this. Thanks
for any help. My code is below:

Private Sub Report_Page()

Dim intPage As Integer

intPage = Me.Pages
Forms![FaxEmployment2]![txtComputerPrintouts] = intPage - 1

End Sub
 
I have report that I need to have the number of pages counted and then the
number placed in a text box on a form. I am able to do this using the below
code in the report. The problem is first the report has be previewed or
printed before it performs this operation.

Can I get the number of pages of the report without having to print or
preview it and the user seeing this happen? i.e. It does not matter if the
report is opened or previewed as long as the user does not see this. Thanks
for any help. My code is below:

Private Sub Report_Page()

Dim intPage As Integer

intPage = Me.Pages
Forms![FaxEmployment2]![txtComputerPrintouts] = intPage - 1

End Sub

Make sure there is a control in the report that calculates [Pages].

Then, code the [FaxEmployment2] form (not in the report) to open the
report hidden, read the [Pages] and then close the report.

DoCmd.OpenReport "ReportName", acViewPreview, , , acHidden
Me.[txtComputerPrintouts] = reports!ReportName.[Pages]
DoCmd.Close acReport, "ReportName"
 
Back
Top