Is there any way to count the number of pages in a report in VBA? All i want to do is keep the user from printing the report if it is more than 1 page.
My guess is that what would cause the report to be more that one page is the number of records in the report's record source. If this is true, you could use VBA code to check the record count of the report's record source. If within the desired range of records then open the report.
Yes, this is true but some of the records are longer/larger than others and since it is set to allow the records to grow/wrap this method would end up being fairly inacurate. I probably should have stated that earlier but there it is now... Thx for the try though
Any other ideas would be appreciated.
Is there not some way to get the value from the text box on the report that gives the page number? OR
If there is a way to tell it to move to the next page on the open event then if it gives an error "resume next" and it's ok to open or if there isnt then close the report.
Dim intTotalPages As Integer
Dim strMsg As String
intTotalPages = Me.[Pages]
strMsg = "This report contains " & intTotalPages & " pages."
If intTotalPages > 1 Then
MsgBox strMsg
End If
Dim intTotalPages As Integer
Dim strMsg As String
intTotalPages = Me.[Pages]
strMsg = "This report contains " & intTotalPages & " pages."
If intTotalPages > 1 Then
MsgBox strMsg
End If