Dynamic Page Header Based on Page Contents

Endgame

Registered User.
Local time
Yesterday, 21:35
Joined
Aug 20, 2007
Messages
15
Greetings,

I need to make a page header that varies according to what text appears on a particular page. For example, page 1 of a report might contain information on product categoy 'Dispensers' so I need the page header to read "Dispensers". Page 2 might contain information on product categories "Handles", "Covers", and "Plates" so I need the page header for page 2 to read "Handles Covers Plates".

I can assemble the string which identifies which categories find their way on a particular page and I can put this string in the page footer with no problem. I can't seem to get the page header to update (I believe) because the format and print events for the PageHeaderSection have already passed by the time I assemble the category string.

Does anyone know how to revisit the PageHeaderSection events or cause them to run again?

Regards,
Endgame
 
I have solved my own problem by figuring out how to "read ahead" while Access is doing it's first pass at formatting the report's pages. Haveagoodday!
 
Any channce of you sharing some of your code, sounds interesting?

Cheers
 
Peter,

Thanks for the interest. I'm currently caught up in a project so will have to make due (for now) with generals on the methodology I used.

I appears that Access makes at least 2 'passes' while generating a report preview. Pass1 appears to visit all of a report's (and embedded subreport's) sections (ie. report_header, pageheadersection, groupheader, detail, etc.) and generates the format without issuing a print. I believe this is for Access to see how many pages are in the report and what detail sections will appear on what page. This Pass1 is conducted on the whole report at one time --> section formats are processed until the end of a page is met and then Access probably records how much stuff was on this one page then more section formats are processed until the end of the next page is reached, and so on.

Pass2 to is processed a page at a time based on the results of Pass1. Access seems to remember what fit on a page and will only process the format and print actions that will fit on a given page.


So................

On Pass1, I calculate (accumulate, really) what I want to be on a given page's header while the body of the page is being figured out. When I see the end of a page reached in Pass1, I stuff the header into a run-time Array (page1 header goes into index 1 spot in the array) to await Pass2. When Pass1 finishes, my array contains all my headers. During Pass2 PageHeaderSection_Format events, I set a text box in the header section equal to the array place on the page that is currently printing.

Regards,
Endgame
 
Thanks for the reply.
How did you 'see' there were two passes?
You have obviously been able to break into the process between them, to write your array, so any could any control's value be changed at that time, do you think?

Cheers
 
It hurt badly, but I put break points in every section's OnFormat, OnPrint, and OnRetreat event and then kicked off the report preview. As Access chugged through the breakpoints, I noted the progress through the report's sections. During Pass1, you only see OnFormat and OnRetreat events.

Simple example using forms called z4 and it's subform rA.
Notation used:
RH_F = ReportHeader_Format Event
RH_P = ReportHeader_Print Event
RF_F = ReportFooter_Format Event
RP = Report_Page Event
PHS_F = PageHeaderSection_Format Event
PHS_P = PageHeaderSection_Print
PFS_F = PageFooterSection_Format
PFS_P = PageFooterSection_Print
DF = Detail_Format
DR = Detail_Retreat
DP = Detail_Print

Following are the breakpoints my form z4 and rA attained during Pass1
z4: RH-F PHS_F DF
rA: RH_F DF DF DF DF DF DR DR DR DR DR RH_F DF DF DF DF
<<progress note: it appears Access while processing rA that the fifth detail would not fit on the first page so it backed out thru the five details, reaccomplished the rA form header formatting, then did four deatil formattings>>
z4:PFS_F
<<progress note: page1 content determination has been finished and I stuff my calculated header, which is accumulated during the DF events, into my array([Page])>>
z4: PHS_F DF
rA: DF DF DF DF DF DR DR DR DR DR DF DF DF DF DF
z4: PFS_F
<<progress note: page2 content determination has been finished and I stuff my calculated header, which is accumulated during the DF events, into my array([Page])>>
z4: PHS_F DF
rA: DF DF DF
<<progress note: the rA subreport has run out of data at this point so now the rA report footer processes>>
rA: RF_F RF_R DR DR DR
z4: RF_F PFS_F
<<progress note: page3 content determination has been finished and I stuff my calculated header, which is accumulated during the DF events, into my array([Page])>>
<<progress note: Pass2 begins now and includes print events>>
z4: RH_F RH_P PHS_F
<<progress note: at this point I start setting my header text box to array([Page]) to get my stored header value>>
z4: PHS-P DF
rA: RH_F DF DF DF DF DF DR DR DR DR DR
z4: DP
rA: RH_F RH_P DF DP DF DP DF DP DF DP
Z4: PFS_F PFS_P R_P
<<progress note: page1 preview finally appears. Even wonder why it takes a while for the preview to go from page to page? There's a lot of stuff going on.>>

Haveagoodday,
Endgame
 
Peter,

Sorry that I didn't directly reply to your question "could any control's value be changed at that time".

I believe the answer to be "yes" as long at the control in question isn't modified by another step farther down along the formatting passes.
Regards,
Endgame
 
I don't completely understand your soloution but from what I have gathered I have having trouble with something similar.

What I'm trying to do is described here
http://www.access-programmers.co.uk/forums/showthread.php?t=102886

Basically I have two image controls and I set the Picture property in the Detail_Format routine based off of a URL stored in the database. When there is a URL in the database the proper picture is shown. However, if there is no URL in the database the image control for that record has the previous reports image (or last maybe?)

So the picture property is set by
Code:
Image1.Picture = Nz(Me.Photo1, "")

However, if there is no picture to display I can't seem to get it to set the Picture property to Null or empty string so that no picture shows up.
 
Does anyone have an idea why the image control won't update? I'm banging my head against a wall with this one. It seems like I don't have the same options for controls on the report than I do when working with controls on a form.
 

Users who are viewing this thread

Back
Top Bottom