Showing PageHeader in Subreport

Need some input, guys!

I've got a report where the main report is a dynamic cover letter.  There are three subreports in the main report's ReportFooter.  They were (key word being were) all one pagers so I was able to make each individual subreport's ReportHeader act as a Page Header.  Well, the last subreport has now gone to 2 pages so there is no header on it's second page.

I had the idea of placing the final report's header in the main report's unused PageHeader, initializing it as not visible and changing it to visible on the final page of the last subreport.

Clear as mud, yet?

Well, in theory good, but, how do I reference the Visible property of the main report's PageHeader and change it?  I can do this for an individual control but what about the entire PageHeader section?

BTW, I am using Access 2003.  And need quick input.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How about
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Me.PageHeader.Visible = False

End Sub
Jim HornSQL Server Data DudeCommented:
Can't do it.  PageHeaders are turned off in Subreports, as subs are not able to detect when the main report moves from one page to another.

You can do this in the main report's Page Header property though...

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

If Me.Page = 1 then
         'Do page 1 stuff, set controls you wish to view .Visible=True, others .Visible=False
         'Do page 2, 3, .. stuff, set controls you wish to view .Visible=True, others .Visible=False
End If

End Sub

Hope this helps.

Leigh PurvisDatabase DeveloperCommented:
Do you know how many pages in total the report will be?
You can put in the format event of the report
If Page = 5 then
PageHeaderSection.Visible = True
End if

or for the last page only..
If Page = Pages then
PageHeaderSection.Visible = True
End if
5 Ways Acronis Skyrockets Your Data Protection

Risks to data security are risks to business continuity. Businesses need to know what these risks look like – and where they can turn for help.
Check our newest E-Book and learn how you can differentiate your data protection business with advanced cloud solutions Acronis delivers


Try using a group header and set the RepeatSection property to Yes in the group header's property sheet.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lmerrellAuthor Commented:
Thought of that, Jim, but was looking for a quicker way around it as there are a buttload of controls in the header.  But that may be the best solution.

LPurvis - You cannot access the PageHeader's visible property like that.  You get an invalid qualifier error at runtime.  In fact, Intellisense doesn't recognize any of the properties when coding it.

Any other ideas?
Jim HornSQL Server Data DudeCommented:
Fun.  One way to manage this when controls.count = buttload is to give them all a standard naming prefix, such as "p1_" or "p2_", then...

Dim ctl as Control, bVisible as Boolean

If Me.Page = 1 then
   bVisible = True
   bVisible = False
End If

For Each ctl in Me.PageHeaderSection.Controls
   If left(ctl.Name, 3) = "p1_" then
      ctl.Visible = bVisible
      ctl.Visible = Not bVisible
   End IF

Leigh PurvisDatabase DeveloperCommented:
We're talking about the Main report here yes?
lmerrellAuthor Commented:
Bingo, mbizup!  Just had to add a group header at the highest level of the subreport's data and set the RepeatSection to Yes.  Thanks a bunch!  Owe you a cold one in addition to the 500 points.

lmerrellAuthor Commented:
Yeah, Jim.  That would have been the approach I would have used but I knew there had to be some other easier method.

BTW, been quite awhile since I wandered in here.  I've moved on to the .NET world now.  This is for a legacy system of ours.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.