ACC2000: Error When Closing Form That Instantiates a Class Module

ID: Q223245


The information in this article applies to:

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

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


SYMPTOMS

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:

This program has performed an illegal operation and will be shut down.

If the problem persists, contact the program vendor.
When you click Details, the following message appears:
MSACCESS caused an invalid page fault in MSACCESS.EXE at 015f:300581e7.
NOTE: The actual memory address may vary.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Access database.


  2. In the Database window, click Modules under Objects.


  3. On the Insert menu, click Class Module. A new module opens.


  4. In the new class module, type the following code:


  5. 
    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 
  6. Save the class module as Class1 and close the Visual Basic Editor.


  7. In the Database window, click Forms under Objects, and then click Create form in Design View.


  8. On the View menu, click Code. A new module opens.


  9. Type the following in the module:


  10. 
    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 
  11. Save the form and view it in Form view.


  12. On the File menu, click Close.


Note that either Microsoft Access stops responding, or you see the error message mentioned in the "Symptoms" section.


REFERENCES

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