ACC2: Code Called from OnFormat Creates Endless Formatting (113929)



The information in this article applies to:

  • Microsoft Access 2.0

This article was previously published under Q113929
Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

A report that calls code from its OnFormat property may never finish formatting and may become stuck in an internal page formatting loop. This problem may be more common in databases that have been converted from Microsoft Access version 1.x to version 2.0.

RESOLUTION

Press CTRL+BREAK to break the internal processing loop.

With the addition of two-pass formatting for reports in Microsoft Access version 2.0, events previously called from the OnFormat property may need to be called from the OnPrint property instead. Or, use the KeepTogether property in the report's Sorting And Grouping dialog box to keep groups of records together.

Note that the sample code in the "Steps to Reproduce Problem" section later in this article is similar to the sample code in article 100920, "How to Avoid Abandoned Group Headers in Reports."

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

Steps to Reproduce Problem


  1. Open the sample database NWIND.MDB.
  2. Create a new, blank report based on the Catalog query.
  3. From the View menu, choose Sorting And Grouping.
  4. In the first Field/Expression row, select Category Name. Set the GroupHeader property to Yes.
  5. In the next Field/Expression row, select Product Name.
  6. Close the Sorting And Grouping dialog box.
  7. Drag the Product Name field from the field list to the detail section of the report. Set the height of the detail section to 0.25 inches.
  8. Drag the Category Name field from the field list to the Category Name header section. Set the height of the header section to 0.5 inches.
  9. Set the Category Name header section's OnFormat property to the following event procedure:
           Sub GroupHeader3_Format (Cancel As Integer, FormatCount As Integer)
             If Me.Top > 4.75 * 1440 Then
               Me.MoveLayout = True
               Me.NextRecord = False
               Me.PrintSection = False
             End If
           End Sub
    						

    NOTE: To create this event procedure, click in the OnFormat property field, then choose the Build button. In the Choose Builder dialog box, select Code Builder. Enter the code in the module, and then close the module.
  10. Preview the report.
  11. Press CTRL+BREAK to break out of the endless formatting loop.

Modification Type:MajorLast Reviewed:7/8/2002
Keywords:kbbug kbusage KB113929