ACC2000: Module Disappears After Running Code

ID: Q223199


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

Running code in a module may cause the module to disappear.


CAUSE

When you are running code in a new, unsaved module and the code includes the programmatic creation and saving of another new module, the module that contains the running code disappears.


RESOLUTION

Because existing (saved) modules are not affected when new modules are created programmatically, ensure that the active module is compiled and saved before you run it.

Unfortunately, there is no way to recover a module that has disappeared because of this issue.


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. Open the sample database Northwind.mdb.


  2. Create a new module. Note the module's name, Module1, in the Project Explorer window.


  3. On the Tools menu, click References.


  4. Click to select (check) the Microsoft Visual Basic for Applications Extensibility <Version> check box.


  5. Type the following line in the Declarations section:


  6. 
    Option Explicit 
  7. Type the following procedure:


  8. 
    Sub CreateMod()   
       Dim myModule as Object
       Set myModule = Application.VBE.VBProjects("Northwind"). _
          VBComponents.Add(vbext_ct_StdModule)
    
       ' The following line causes the module to disappear
       DoCmd.Save acModule, myModule.Name
    End Sub 
  9. With the pointer inside the function, click Run Sub/Userform on the Run menu.

    Note that a new module has been created, Module2, and the initial module, Module1, no longer appears in the Project Explorer window.


Additional query words: pra deleted delete removed remove

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


Last Reviewed: July 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.