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

Last reviewed: January 13, 1998
Article ID: Q104760
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

  1. Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).

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

  3. Open the Employee Sales By Country report in Design view.

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

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

  1. Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).

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

  3. Open the Employee Sales By Country report in Design view.

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

  5. Set the ForceNewPage property to After Section.

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


Additional query words: Custom
Keywords : RptLayou kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 13, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.