Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2002
    Location
    San Francisco, California
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report Page Count (Access 2K)

    I've incorporated the code below in my report's page event. It does exactly what I want it to do: Count the number of pages in the report and have a message box pop-up indicating the # of pages.

    But the message pops up every time I go from page to page. Is it because it's in the Page event, so the message will pop-up for every page? How can I avoid having the message pop-up for every page?

    Private Sub Report_Page()
    'Count the number of pages in the report and have a message box pop-up indicating the # of pages

    Dim intTotalPages As Integer

    intTotalPages = Me.Pages

    MsgBox ("This report contains " & intTotalPages & " pages. Be sure you have enough paper in the printer."), _
    vbOKOnly + vbExclamation, "Order Review Program Report"

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report Page Count (Access 2K)

    Add a static variable to keep track of whether the message has been displayed:

    Private Sub Report_Page()
    Static blnShown As Boolean
    Dim intTotalPages As Integer

    If blnShown = True Then Exit Sub

    intTotalPages = Me.Pages

    MsgBox ("This report contains " & intTotalPages & " pages. Be sure you have enough paper in the printer."), _
    vbExclamation, "Order Review Program Report"
    blnShown = True
    End Sub

  3. #3
    New Lounger
    Join Date
    Nov 2002
    Location
    San Francisco, California
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report Page Count (Access 2K)

    Works perfectly, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •