ACC2000: Error When You Close a Form That Instantiates a Class Module (223245)
The information in this article applies to:
This article was previously published under Q223245 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 try to close a form that contains code that instantiates a class object, Microsoft Access may stop responding (hang), or you may receive the following error message:
This program has performed an illegal operation and will be shut down.
If the problem persists, contact the program vendor.
When you click Details (on Microsoft Windows Millennium Edition, press ALT+D), you receive the following message: MSACCESS caused an invalid page fault in MSACCESS.EXE at 015f:300581e7.
NOTE: The actual memory address may vary.
CAUSE
This problem occurs when both of the following are true:
- You use WithEvents in the Class module to track the form's events.
- In the Close or Unload event of the form, you destroy an object with the following statement:
Set object = Nothing
RESOLUTION
To avoid receiving the error message mentioned in the "Symptoms" section of this article, create a custom command button on the form to destroy the object and to close the form. To do so, follow these steps:
- Open the form in Design View.
- Add a command button to the form, and then set the OnClick property of the command button to the following event procedure:
Set fObj = Nothing
DoCmd.Close
- Open the form in Form view, and then close the form with the command button. Note that the form closes without error.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. REFERENCESFor more information about class modules, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type class modules in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 6/24/2004 |
---|
Keywords: | kbbug kberrmsg kbpending KB223245 |
---|
|