ACC2000: Error When Closing Form That Instantiates a Class ModuleID: Q223245
|
If you try to close a form containing code that instantiates a class object, Microsoft Access may stop responding (hang), or you may receive the following error message:
When you click Details, the following message appears:This program has performed an illegal operation and will be shut down.
If the problem persists, contact the program vendor.
NOTE: The actual memory address may vary.MSACCESS caused an invalid page fault in MSACCESS.EXE at 015f:300581e7.
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.
Option Explicit
Private WithEvents fForm As Form
Sub Init(pForm As Form)
If fForm Is Nothing Then
Set fForm = pForm
End If
End Sub
Private Sub Class_Initialize()
Debug.Print "Object is initialized"
End Sub
Private Sub Class_Terminate()
Debug.Print "Object is terminated"
End Sub
Option Compare Database
Option Explicit
Private fObj As New Class1
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
fObj.Init Me
Exit_Form_Open:
Exit Sub
Err_Form_Open:
Cancel = True
MsgBox Err.Description
Resume Exit_Form_Open
End Sub
Private Sub Form_Close()
Set fObj = Nothing
End Sub
For 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.
Additional query words: pra
Keywords : kberrmsg kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: May 27, 1999