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



The information in this article applies to:

  • Microsoft Access 1.0
  • Microsoft Access 1.1
  • Microsoft Access 2.0
  • Microsoft Access for Windows 95 7.0
  • Microsoft Access 97

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


  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.

Modification Type:MajorLast Reviewed:5/6/2003
Keywords:kbhowto kbusage KB104760