Chapter 20: Advanced Access Report Techniques
719
Hiding a page header
Sometimes you need to display a page header or footer on just the first page of a report. An exam-
ple is a terms and conditions clause in the header of the first page of an invoice. You want the
terms and conditions to appear only on the first page of the invoice but not on subsequent pages.
Add an unbound text-box control to the report with its ControlSource property set to the
expression =HideHeader(). Delete the text box’s label and set the text box’s text color to white
and its border to transparent to make it invisible on the report.
Note
You can’t actually set the control’s Visible property to No; if you did, the control wouldn’t be able to
respond to events.
The HideHeader() function is as follows:
Function HideHeader()
Reports![rptInvoice].Section(3).Visible = False
‘Section(3) is a reference to the
‘report page header reference
HideHeader = True
End Function
The invisible text box can be placed virtually anywhere on the first page but is most logically
located in the page footer. The assumption is that, because the page header is the first item printed
on the page, you’ll always get the first page header. Once the page footer containing the invisible
text box has been processed, the page header’s Visible property will be set to False, and the
page header will not be seen on any other pages in the report.
Starting a new page number for each group
Sometimes a report will contain a number of pages for each group of data. You might want to reset
page numbering to 1 as each group prints, so that each group’s printout will have its own page-
numbering sequence. For example, assume you’re preparing a report with sales data grouped by
region. Each region’s sales may require many pages to print, and you’re using the ForceNewPage
property to ensure that grouped data doesn’t overlap on any page. But how do you get the page
numbering within each group to start at 1?
The report’s Page property, which you use to print the page number on each page of a report, is a
read/write property. This means that you can reset Page at any time as the report prints. Use the
group header’s Format event to reset the report’s Page property to 1. Every time a group is for-
matted, Page will be reset to 1 by the following code:
Private Sub GroupHeader2_Format ()
Me.Page = 1
End Sub