ACC2002: Problems Using Requery and Refresh Methods During Pivot Events (288374)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q288374
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you call the Requery or Refresh methods from certain events in a form, one of the following occurs:

  • You receive the following error message, and then Microsoft Access shuts down:
    Microsoft Access has encountered a problem and needs to close. We are sorry for the inconvenience.
    When you view the details in the error report, the report says that an error occurred in Owc10.dll.
  • Microsoft Access stops responding indefinitely, forcing you to have to press CTRL+ALT+DELETE to end the task.

CAUSE

The Requery or Refresh method causes infinite recursion, or an endless loop, that eventually causes Microsoft Access to quit or to stop responding.

RESOLUTION

Use these methods from a different event that does not cause infinite recursion.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

When you call data-related methods, such as Requery or Refresh, your code can cause infinite recursion, or an endless loop, if the method is called from certain events. This is because the action that the method performs causes the form event to fire repeatedly.

For example, the Query event of a form fires when the PivotTable of a form queries its data source. If you call the Requery or Refresh method from the Query event of a form, the recordsource of the form is requeried (or refreshed). This causes the PivotTable of the form to query its data source a second time, which causes the Query event of the form to fire again. The code in the Query event executes again, which causes the recordsource to be requeried (or refreshed) again. This causes the Query event to fire a third time. This process continues until Microsoft Access quits.

Not all events will cause Microsoft Access to quit with the error message that is mentioned in the "Symptoms" section of this article with the Requery or Refresh methods. If you call these methods from some other events, Access may not respond at all without ever returning an error message. This forces you to have to press CTRL+ALT+DELETE to end the task. You should not call the Requery or Refresh methods from any of the following events in a form:
  • AfterFinalRender
  • AfterRender
  • BeforeQuery
  • BeforeRender
  • CommandBeforeExecute
  • CommandChecked
  • CommandEnabled
  • CommandExecute
  • Current (Even though this is not a Pivot related event, calling these methods will cause Microsoft Access to stop responding.)
  • DataChange
  • DataSetChange
  • OnConnect
  • PivotTableChange
  • Query
  • SelectionChange
  • PivotTableChange

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb.
  2. On the Insert menu, click Form.
  3. In the New Form dialog box, click Form Wizard, and then click OK.
  4. In the Form wizard, click the arrow in the Tables/Queries box, and then click Tables: Orders in the drop-down list.
  5. Add all the fields to the Selected Fields list, and then click Finish. Note that a new form that is based on the Orders table is created in Form view.
  6. On the View menu, click Design View.
  7. On the View menu, click Code to view the module of the form.
  8. Add the following code to the module of the form:
    Private Sub Form_Query()
       Me.Requery
    End Sub
    					
  9. On the File menu, click Close and Return to Microsoft Access.
  10. On the File menu, click Save.
  11. Close the form.
  12. Open the form in Form view.
  13. On the View menu, click PivotTable View.
Note that you receive the following error message, and then Microsoft Access quits:
Microsoft Access has encountered a problem and needs to close. We are sorry for the inconvenience.
When you view the details in the error report, the report says that an error occurred in Owc10.dll.

REFERENCES

For more information about form events in Microsoft Access, in the Microsoft Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type the name of the event, such as query event, in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:11/6/2003
Keywords:kbbug kberrmsg kbnofix KB288374