Having a problem with code from 2003 to 2007

  • Thread starter diablowrym via AccessMonster.com
  • Start date
D

diablowrym via AccessMonster.com

I am using the following code to make my pagefooter only appear on the first
page of my report.

Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)

If [Page] = [Pages] Then
Me.PageFooterSection.Visible = True
Else
Me.PageFooterSection.Visible = False
End If

End Sub


This is working fine in the 2003 version that I have on my pc, but on other
pc's in the office that have 2007 it is not working.

Anyone have any ideas how to fix this, or other code I could use,
Thanks,
Point
 
A

Allen Browne

There are several issues here:

1. Your code shows the page footer on the last (not first) page only.
(Presumably that's what you intend.)

2. It's better to use the Format event rather than Print to show/hide stuff.

3. You need the code in the Page Header section's Format event. Doing in in
the Page Footer will only affect the next page, and since it reveals the
footer on the last page, it never happens.

4. (Optional.) The code will run faster if you only set the property when it
needs changing rather than every time.

This works in A2003 and A2007:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim bShow As Boolean
bShow = (Me.Page = Me.Pages)
With Me.Section(acPageFooter)
If .Visible <> bShow Then
.Visible = bShow
End If
End With
End Sub
 
D

diablowrym via AccessMonster.com

Thanks Allen,
I will try the code you suggested. I know the code looks like it would be on
the last page, I had it the other way around at first and it only showed on
the last page..Worked that for a couple off hours and then tried it like it
is and it worked..go figure.

Allen said:
There are several issues here:

1. Your code shows the page footer on the last (not first) page only.
(Presumably that's what you intend.)

2. It's better to use the Format event rather than Print to show/hide stuff.

3. You need the code in the Page Header section's Format event. Doing in in
the Page Footer will only affect the next page, and since it reveals the
footer on the last page, it never happens.

4. (Optional.) The code will run faster if you only set the property when it
needs changing rather than every time.

This works in A2003 and A2007:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim bShow As Boolean
bShow = (Me.Page = Me.Pages)
With Me.Section(acPageFooter)
If .Visible <> bShow Then
.Visible = bShow
End If
End With
End Sub
I am using the following code to make my pagefooter only appear on the
first
[quoted text clipped - 18 lines]
Thanks,
Point
 
D

diablowrym via AccessMonster.com

Thanks again Allen,
What I want to do is have the page footer only print on the First page. I'm
not the best with code, but when I tried the code you supplied it prints the
footer on the last page only. I tried changing it and the I had the footer on
every page.
I'm trying to match a two part form from one of our departments. You will
have one first page and many pages after that. I can suppess the page header
on the first page easy and have it on all remaining pages, but the footer
must only be on the first page.

Thank you, Point

Allen said:
There are several issues here:

1. Your code shows the page footer on the last (not first) page only.
(Presumably that's what you intend.)

2. It's better to use the Format event rather than Print to show/hide stuff.

3. You need the code in the Page Header section's Format event. Doing in in
the Page Footer will only affect the next page, and since it reveals the
footer on the last page, it never happens.

4. (Optional.) The code will run faster if you only set the property when it
needs changing rather than every time.

This works in A2003 and A2007:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim bShow As Boolean
bShow = (Me.Page = Me.Pages)
With Me.Section(acPageFooter)
If .Visible <> bShow Then
.Visible = bShow
End If
End With
End Sub
I am using the following code to make my pagefooter only appear on the
first
[quoted text clipped - 18 lines]
Thanks,
Point
 
A

Allen Browne

Change the 2nd line to:
bShow = (Me.Page = 1)
so it shows only on page 1.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

diablowrym via AccessMonster.com said:
Thanks again Allen,
What I want to do is have the page footer only print on the First page.
I'm
not the best with code, but when I tried the code you supplied it prints
the
footer on the last page only. I tried changing it and the I had the footer
on
every page.
I'm trying to match a two part form from one of our departments. You will
have one first page and many pages after that. I can suppess the page
header
on the first page easy and have it on all remaining pages, but the footer
must only be on the first page.

Thank you, Point

Allen said:
There are several issues here:

1. Your code shows the page footer on the last (not first) page only.
(Presumably that's what you intend.)

2. It's better to use the Format event rather than Print to show/hide
stuff.

3. You need the code in the Page Header section's Format event. Doing in
in
the Page Footer will only affect the next page, and since it reveals the
footer on the last page, it never happens.

4. (Optional.) The code will run faster if you only set the property when
it
needs changing rather than every time.

This works in A2003 and A2007:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim bShow As Boolean
bShow = (Me.Page = Me.Pages)
With Me.Section(acPageFooter)
If .Visible <> bShow Then
.Visible = bShow
End If
End With
End Sub
I am using the following code to make my pagefooter only appear on the
first
[quoted text clipped - 18 lines]
Thanks,
Point
 

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