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:
Open the report you want to print double-sided (or even single-sided, with different odd and even headers and footers).
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).
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 SubYou’ll need to replace the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access