ACC2: OnFormat Event Procedure Triggered Too Early

Last reviewed: May 14, 1997
Article ID: Q128223
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

The OnFormat event procedure is triggered on the page before a group header or a group footer section is printed. This problem happens when the ForceNewPage property is set to Before Section to force the section to print on the next page. For example, the event is triggered on page 1, but the section prints on page 2.

CAUSE

If a group header or group footer section's Height property is set to 0 inches, the OnFormat event property is triggered before the section is moved to the next page rather than after.

RESOLUTION

To work around this problem, set the group header or group footer section's Height property to at least .007 inches.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.

MORE INFORMATION

The behavior described above can also reset the page number for a group header or group footer incorrectly.

Steps to Reproduce Behavior

CAUTION: Following the steps in the example will modify the sample database NWIND.MDB. You may want to back up the NWIND.MDB file, or perform these steps on a copy of the NWIND database.

  1. Open the sample database NWIND.MDB, and create a new macro as follows:

          Macro Name          Action
          --------------------------
          GroupHeaderFrmt     MsgBox
    
          GroupHeaderFrmt Actions
          -------------------------------------------
          MsgBox
             Message: =[Category Name] & " " & [Page]
    
    

  2. Open the List Of Products By Category report in Design view.

  3. Move the Category Name text box in the Category Name group header section to the detail section.

  4. Set the properties for the Category Name group header section as follows:

          ForceNewPage: Before Section
          OnFormat: GroupHeaderFrmt
          Height: 0
    

  5. Preview the report. Note that the message box displays "Beverages1."

Steps to Work Around Problem

  1. In step 4 above, increase the Category Name group header section's Height property to .007.

  2. Preview the report. Note that no message is displayed until you preview page 2.

REFERENCES

Microsoft Access "User's Guide," version 2.0, Chapter 22, "Sorting and Grouping Data," pages 547-580

For more information about sorting and grouping, search for "Sorting and Grouping," and then "Sorting and Grouping Command (View Menu)" using the Microsoft Access Help menu.

For more information about resetting the page number with group headers and footers, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q104760
   TITLE     : ACC: How to Reset the Page Number on Group Level in a Report
 

	
	


Keywords : kbusage RptLayou
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbbug
Resolution Type : kbworkaround


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: May 14, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.