Controls on Page Header

G

Guest

On an Access Report, I would like two controls to be visible on the page
header section only if they appear on the first page.

While the If clause in the following statement is not triggered on the first
page, it is triggered on subsequent pages, but the control is rendered
invisible on all pages.

Any ideas how I can get the control to remain visible on only the first page?

- - - - - - - -

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

If Me.Page <> 1 Then
With Me.ControlName
.Visible = False
.Top = 0
.Left = 0
.Height = 0
.Width = 0
End with
End If
 
F

fredg

On an Access Report, I would like two controls to be visible on the page
header section only if they appear on the first page.

While the If clause in the following statement is not triggered on the first
page, it is triggered on subsequent pages, but the control is rendered
invisible on all pages.

Any ideas how I can get the control to remain visible on only the first page?

- - - - - - - -

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

If Me.Page <> 1 Then
With Me.ControlName
.Visible = False
.Top = 0
.Left = 0
.Height = 0
.Width = 0
End with
End If

In the Page Header Format event:
Me![ControlName].Visible = Me.[Page] = 1

Why were you attempting to set the other properties to 0 if the
control is not going to be visible anyway?
 
M

Marshall Barton

Developer said:
On an Access Report, I would like two controls to be visible on the page
header section only if they appear on the first page.

While the If clause in the following statement is not triggered on the first
page, it is triggered on subsequent pages, but the control is rendered
invisible on all pages.

Any ideas how I can get the control to remain visible on only the first page?

- - - - - - - -

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

If Me.Page <> 1 Then
With Me.ControlName
.Visible = False
.Top = 0
.Left = 0
.Height = 0
.Width = 0
End with
End If


You should set the properties appropriately for page 1 too.
There are situations (e.g. you used Pages in a text box)
when a report must be processed twicw and your setting for
the last page is still in effect the second time the first
page is formatted.

Note that you do not need to set the position properties.
Making it invisible is sufficient. I'm pretty sure all you
need is this one line:

Me.ControlName.Visible = (Me.Page = 1)
 
G

Guest

Thanks Fredg!

That works. Do you know why your code works, but mine did not? (Mine made
the control invisible on all pages, even though it evaluated properly for
page 1.)

I changed the other properties of the control (Top, Left, Height, Width) so
that the section would resize properly (I also changed the
Me.PageHeaderSection.Height property to resize the Header height.)

Is that the problem? Can the PageHeaderSection.Height property be different
on each page, or does it have to be the same for all pages? Perhaps the
control was visible, but the PageHeaderSection.Height was too low, so it did
not show up.

Thanks again!

fredg said:
On an Access Report, I would like two controls to be visible on the page
header section only if they appear on the first page.

While the If clause in the following statement is not triggered on the first
page, it is triggered on subsequent pages, but the control is rendered
invisible on all pages.

Any ideas how I can get the control to remain visible on only the first page?

- - - - - - - -

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

If Me.Page <> 1 Then
With Me.ControlName
.Visible = False
.Top = 0
.Left = 0
.Height = 0
.Width = 0
End with
End If

In the Page Header Format event:
Me![ControlName].Visible = Me.[Page] = 1

Why were you attempting to set the other properties to 0 if the
control is not going to be visible anyway?
 
G

Guest

Thanks Marshall!

Any thoughts on my above reply to fredg? Is the real problem here that I
set Me.PageHeaderSection.Height? Does that properly have to be the same for
all pages?
 
J

John Spencer

How about you set the control's visibility to false in the format event and
by the time you got to the print event the control was no longer visible.


"Developer of the Caribbean"
 
M

Marshall Barton

Changing the height of the control is fine if you really
needed to do that, but in this case its just a waste of time
and you would have to add more code to set it back to its
original position and size in the report header's Format
event.

As I said before, the use of Pages in a text box is the
common reason why your code didn't appear to work. The
reason our code did work is strictly because it makes the
control visible when needed (and invisible otherwise).
 
G

Guest

Thanks Marshall. I think I've got it now.

Marshall Barton said:
Changing the height of the control is fine if you really
needed to do that, but in this case its just a waste of time
and you would have to add more code to set it back to its
original position and size in the report header's Format
event.

As I said before, the use of Pages in a text box is the
common reason why your code didn't appear to work. The
reason our code did work is strictly because it makes the
control visible when needed (and invisible otherwise).
--
Marsh
MVP [MS Access]

Any thoughts on my above reply to fredg? Is the real problem here that I
set Me.PageHeaderSection.Height? Does that properly have to be the same for
all pages?
 
S

slickdock

Similar problem. How can I make the entire Page Header invisible on page 1
and visible >Page 1? Rather than code each control separately, I'd like to
code the entire header.
 
D

Dirk Goldgar

slickdock said:
Similar problem. How can I make the entire Page Header invisible on page 1
and visible >Page 1? Rather than code each control separately, I'd like to
code the entire header.


Have you tried code like this in the Format event of the PageHeader section?

'----- start of code -----
Private Sub PageHeaderSection_Format( _
Cancel As Integer, _
FormatCount As Integer)

Me.PageHeaderSection.Visible = (Me.Page > 1)

End Sub

'----- end of code -----
 
F

fredg

Similar problem. How can I make the entire Page Header invisible on page 1
and visible >Page 1? Rather than code each control separately, I'd like to
code the entire header.

Set the Report's PageHeader property to
Not with Rpt Hdr
It's found on the report property sheet's Format tab.
 
D

Dirk Goldgar

fredg said:
Set the Report's PageHeader property to
Not with Rpt Hdr
It's found on the report property sheet's Format tab.


I'd forgotten that property existed! Nice one, Fred.
 

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