Link to home
Start Free TrialLog in
Avatar of lmerrell
lmerrell

asked on

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.

Thanks,

lmerrell
Avatar of tbsgadi
tbsgadi
Flag of Israel image

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


End Sub
Avatar of Jim Horn
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
Else
         'Do page 2, 3, .. stuff, set controls you wish to view .Visible=True, others .Visible=False
End If

End Sub

Hope this helps.
-Jim

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
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lmerrell
lmerrell

ASKER

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?
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
Else
   bVisible = False
End If

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

We're talking about the Main report here yes?
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.

lmerrell
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.