ACC2000: Module Disappears After Running Code (223199)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q223199
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to 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 that this is a problem in the Microsoft products that are 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:
    Option Explicit
    					
  6. Type the following procedure:
    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
  7. 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.

Modification Type:MajorLast Reviewed:6/28/2004
Keywords:kbbug kbpending KB223199