Microsoft KB Archive/104760

= ACC: How to Reset the Page Number on Group Level in a Report =

Article ID: 104760

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q104760



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
By 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.</li></ol>

If Page Number Is Displayed in Page Header
<ol> Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).</li>  If you are using version 1.x or 2.0, create the following new macro and save it as Pager:

<pre class="fixed_text">     Macro Name  Action Pager      SetValue

Macro Actions SetValue Item: Page Expression: 0 </li> Open the Employee Sales By Country report in Design view.</li>  In Microsoft Access 7.0 or 97:

<pre class="fixed_text">     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:

<pre class="fixed_text">     Select the Country Footer section, and set the OnFormat property to      the Pager macro. </li> Set the ForceNewPage property to After Section.</li> Move the control called Page, which displays the page number, to the page header.</li></ol>

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.

<div class="references_section">