Different page headers

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
 
T

Tony Williams

Actually I want the page header only to appear from page 2 onwards.
Thanks
Tony
 
T

Tony Williams

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
 
K

Klatuu

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top