Print Different Headers or Footers on Odd and Even Pages

Problem

Some of your reports are printed double-sided, and you would like to have mirror-image headers and footers on odd and even pages. How do you do this in Access?

Solution

This technique makes use of two sets of header and footer controls, one for odd pages and one for even pages. An event procedure run from the section’s Format event uses the Page property and the Mod operator to determine whether the page is odd or even and makes the appropriate controls visible or invisible.

The following steps show you how to create your own report that prints different headers and footers on odd and even pages:

  1. Open the report you want to print double-sided (or even single-sided, with different odd and even headers and footers).

  2. Make a copy of the header control, and place one of the copies of the control on the left of the header and the other on the right. Make the lefthand control left-aligned (to print on even-numbered pages) and the righthand control right-aligned (to print on odd-numbered pages).

  3. Create an event procedure attached to the OnFormat property of the report’s page header section. In the event procedure, enter code similar to the following:

    Private Sub PageHeader_Format(Cancel As Integer, FormatCount As Integer)
        On Error GoTo PageHeader_FormatError
        
        Dim fIsEven As Boolean
        
        fIsEven = acbIsEven(Me.Page)
        
        Me![lblTitleLeft].Visible = Not fIsEven
        Me![lblTitleRight].Visible = fIsEven
        
    End Sub

    You’ll need to replace the ...

Get Access Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.