Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Reports: Printing Page Numbers on multi column report

Author(s)
Dev Ashish

    Sometimes it's necessary to print multiple unique page numbers on one physical page of a report. For example, if you're printing a two column phonebook, you might want to display the page numbers under both the columns so that the left column is, say "Page 25 of 60" and the right column is "Page 26 of 60", when there are a total of 30 pages being printed.

    To do this, insert two text boxes in the Page Footer section and assign their properties as follows:

Name:         Textbox1
ControlSource: = [Page]
Visible:    False

Name:        Textbox2
ControlSource: = [Pages]
Visible:    False

    These textboxes are important, because according to Access help, "To Refer to the Pages property in a macro or Visual Basic, the form or report must include a textbox whose ControSource property is set to an expression that uses Pages."

Also create two labels, one underneath the left column, and the other underneath the right column roughly. Call them lblPageNum1 and lblPageNum2.

Then paste this code in the OnPrint event of the page footer.

'************ Code Start ************
' This code was originally written by Dev Ashish
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Sub PageFooter_Print(Cancel As Integer, PrintCount As Integer)
Dim intPage As Integer
  If Me.Page = 1 Then
    intPage = 2
  Else
    intPage = Me.Page * 2
  End If
  With Me
    !lblPageNum1.Caption = "Page " & intPage - 1 & " of " & .Pages * 2
    !lblPageNum2.Caption = "Page " & intPage & " of " & .Pages * 2
  End With
End Sub
'************ Code End  ************

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer