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.
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
|