ACC2000: Undo Method Causes IPF When Used Outside Form's Class Module

ID: Q235222


The information in this article applies to:
  • Microsoft Access 2000

Moderate: Requires basic macro, coding, and interoperability skills.

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


SYMPTOMS

If you invoke the Undo method of a form outside the form module, such as in a global procedure, a global function, or from the Immediate window, you may receive an error similar to one of the following:

Dr. Watson for Microsoft Windows NT

An application error has occurred and an application error log is being generated. MSACCESS.exe Exception: access violation (0xc0000005), Address: 0x3005e7c4

On Microsoft Windows 95/98

MSACCESS caused an invalid page fault in module MSACCESS.EXE at 015f:3005e7c4.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp


RESOLUTION

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

Instead of invoking the Undo method from a public module, call Form.Undo from the code module of the form, as in the following example:

  1. Open the sample database Northwind.mdb.


  2. Create a new form with the following characteristics:


  3. 
       Form: Test1
       -------------------------
       Caption: TestForm
       RecordSource: Categories
    
       Command button
       ------------------------
       Name: Button0
       Caption: My Button
       OnClick: Event Procedure
    
       Text box
       ---------------------------
       Name: CategoryName
       ControlSource: CategoryName
    
       Text box
       --------------------------
       Name: Description
       ControlSource: Description 
  4. In Design view, right-click the command button, and click Build Event on the menu that appears.


  5. Click Code Builder, click OK, and type the following code in the resulting module:


  6. 
    Private Sub Command0_Click()
       Form.Undo
    End Sub 
  7. View the form in Form view and make a change to the description of any record.


  8. Click the command button.


Note that your change was undone and that no error occurs.


STATUS

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


MORE INFORMATION

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.


  2. Create the following new form. and then save it Test1:


  3. 
       Form: Test1
       -------------------------
       Caption: TestForm
       RecordSource: Categories
    
       Text box
       ---------------------------
       Name: CategoryName
       ControlSource: CategoryName
    
       Text box
       --------------------------
       Name: Description
       ControlSource: Description 
  4. View the form in Form view. You do not have to make any changes to any record on the form.


  5. Press CTRL+G to open the Immediate window.


  6. With the form open, type the following in the Immediate window, and then press ENTER:


  7. 
    Forms("Test1").Undo 
Note that you receive one of the errors described in the "Symptoms" section of this article.


REFERENCES

For more information about the Undo method, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type undo in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: pra

Keywords : kbdta AccCon
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: January 27, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.