Link to home
Start Free TrialLog in
Avatar of geeta_m9
geeta_m9

asked on

Want report header to appear on alternate pages only

Is there a way to get MS-Access to print the report header on alternate pages only, i.e., first page, third page, etc. I am printing in duplex, and do not want the alternate pages (e.g., second, fourth, pages etc.) that are printed in the back have the header.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Go into your report's Header section, and add code that goes something like this:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

If Me.Page / 2 = CInt(Me.Page) Then
    'Odd numbered pages
    Me.PageHeaderSection.Visible = True
Else
    'Even numbered pages
    Me.PageHeaderSection.Visible = False
End If

End Sub
Not the report header no, but the page header yes.  Follow Jim's comment.

Jim.
<correction, need more coffee>

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

If Me.Page / 2 = CInt(Me.Page) Then
    'Even numbered pages
    Me.PageHeaderSection.Visible = False
Else
    'Odd numbered pages
    Me.PageHeaderSection.Visible = True
End If

End Sub
Avatar of geeta_m9
geeta_m9

ASKER

Sorry, I meant to say page header, not report header.
I tried inserting your code, but now the header does not appear at all.
Copy-paste your code into this question.
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

If Me.Page / 2 = CInt(Me.Page) Then
    'Odd numbered pages
    Me.PageHeaderSection.Visible = True
Else
    'Even numbered pages
    Me.PageHeaderSection.Visible = False
End If

End Sub
Do:

If Me.Page Mod 2 = 0 Then
    'Even numbered pages
    Me.PageHeader0.Visible = False
Else
    'Odd numbered pages
    Me.PageHeader0.Visible = True
End If

 Note that "PageHeader0" should be the actual name of your page header section.

Jim.
How do I find out what is the name for my page header section?
I looked up the Name under Properties. It is just called PageHeaderSection.
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think it is working because in the Print Preview section, the heading does not come out for the second page. Let me try printing it out.
It looks like it is working, thanks. I just have one concern though. I only manage to test this on one record so far. If I print out multiple records, will they all have the first page with the header and the second page without the header on the reverse side?
BTW, this will only work in Normal (direct to printer) or Preview mode, as code will not fire in the Report view.
That's ok. We just want to print it out.
Actually, I think you want the header on odd numbered pages, not even, so you might want to try:

If Me.Page Mod 2 = 1 Then

If I print out multiple records, will they all have the first page with the header and the second page without the header on the reverse side?
Maybe.  The way this is designed is to print the page header on every other page.  If you have want to print for multiple records, then you will need to ensure that every "record" starts on an odd page.
Well each report will be exactly two pages long.
This morning I printing out the reports and they all look great, thanks.
Thanks for the grade.  Good luck with your project.  -Jim
Thanks!