Different page headers

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

Is it possible to create a different page header on page 1 of a report than
the one that would appear on all the other pages? If so how would I go about
that?
Thanks
Tony
 
Figured it out thanks. For anyone who wants to know I used this code in the
Format property of the Page Header
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Page = 1 Then
Me.Section(acPageHeader).Visible = False
Else: Me.Section(acPageHeader).Visible = True
End If
End Sub

Thanks Tony
 
Tony said:
Figured it out thanks. For anyone who wants to know I used this code
in the Format property of the Page Header
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Page = 1 Then
Me.Section(acPageHeader).Visible = False
Else: Me.Section(acPageHeader).Visible = True
End If
End Sub

All you had to do is set the PageHeader property of the report to "Not with Rpt
Hdr". That suppresses the PageHeader on the first page.
 
Tony,
Rick answered you post, but I would like to suggest a little better coding
style. You make it easier to read. IMHO, all executable code should start on
the first tab in th editor and indented to make it easy to read. Also,
mixing the style of using the : in an If Then statment with new lines can be
confusing. Just as a suggestion for your own benefit and for anyone who has
to read your code later:

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

If Me.Page = 1 Then
Me.Section(acPageHeader).Visible = False
Else
Me.Section(acPageHeader).Visible = True
End If
End Sub

Now, here is a version using With ..End With that reads easily and believe
it or not executes more quickly:

With Me
If .Page = 1 Then
.Section(acPageHeader).Visible = False
Else
.Section(acPageHeader).Visible = True
End If
End With

Now, here is another way.

Me.Section(acPageHeader).Visible = Me.Page <> 1

(Don't you just love VBA :)
White space is stripped out of the compiled version, so it really doesn't
hurt to use it to make it easier us inferior human types.
 
Back
Top