The information in this article applies to:
- Microsoft Access 1.0, 1.1, 2.0, 7.0, 97
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
Using a macro, or some code and a report's section properties, you can
design a report that breaks the page for each new entry in a group and
resets the report's page number. For example, in Microsoft Access 7.0
and 97, the Employee Sales By Country report in the sample database
Northwind.mdb is designed with this feature. In Microsoft Access 1.x
and 2.0 you can redesign the Employee Sales By Country report in the
sample database NWIND.MDB to break the page and reset the page number to 1
for each new country.
MORE INFORMATION
NOTE: The method used to reset the page number for each new country
depends on whether the page number is displayed in the page header or page
footer. If you use the wrong method, the page number is not reset
correctly.
If Page Number Is Displayed in Page Footer
- Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x
and 2.0).
- If you are using version 1.x or 2.0, create the following new macro
and save it as Pager:
Macro Name Action
--------------------
Pager SetValue
Macro Actions
----------------
SetValue
Item: Page
Expression: 1
- Open the Employee Sales By Country report in Design view.
- In Microsoft Access 7.0 and 97:
Select the Country Header section, and then click the Build button
for the OnFormat property to examine the event procedure.
In Microsoft Access 1.x and 2.0:
Select the Country Header section, and then set the section's
OnFormat property to the Pager macro.
- Select the Country footer section and set the ForceNewPage property to
After Section.
NOTE: If you are using Microsoft Access version 1.x or 2.0 and the group
header's Height property is set to 0 inches, the page number is not
reset correctly. To correct this problem, either set the group header's
Height property to at least 0.007 inches or set the group's KeepTogether
property to Whole Section in the Sorting And Grouping dialog box to
force two-pass formatting. This is necessary because the OnFormat
property is triggered too soon when the section has a height of 0
inches.
NOTE: This behavior no longer occurs in Microsoft Access 7.0 or 97.
If Page Number Is Displayed in Page Header
- Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x
and 2.0).
- If you are using version 1.x or 2.0, create the following new macro
and save it as Pager:
Macro Name Action
--------------------
Pager SetValue
Macro Actions
----------------
SetValue
Item: Page
Expression: 0
- Open the Employee Sales By Country report in Design view.
- In Microsoft Access 7.0 or 97:
Select the Country Footer section, and then click the Build button
for the OnFormat property, choose Code Builder, and click OK. In the
code window type the following:
Page = 1
In Microsoft Access 1.x or 2.0:
Select the Country Footer section, and set the OnFormat property to
the Pager macro.
- Set the ForceNewPage property to After Section.
- Move the control called Page, which displays the page number, to the
page header.
When you use either of these methods, each country begins on a new page,
and the numbering of each new pages begins with the number 1.
REFERENCES
For more information about resetting page numbers for each group in a
report, search the Help Index for "resetting page numbers in reports," or
ask the Microsoft Access 97 Office Assistant.
|