ACC2000: Changes That You Make to Referenced Projects Are Not Saved in Visual Basic Editor (202106)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q202106
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

SYMPTOMS

In Microsoft Visual Basic for Applications, you can reference another VBA project (MDB, MDA, or ADP) in the References dialog box. By using the Project Explorer in the Visual Basic Editor, you can also see the code in referenced projects, or you can see the project's properties by clicking Properties on the Tools menu. You can see, and you can even edit the code and properties in a referenced project. However, if you make changes, your changes are not saved. You can save changes only to the project that you have currently open in Microsoft Access.

CAUSE

Access does not save the VBA project in a referenced or a library database. Therefore, any changes that you make to the referenced project--whether at the project level or in a module--are not saved. Access never prompts you to save the changes. Access also never warns you that your changes will not saved.

RESOLUTION

To make changes, open the database. This makes the database the current project. Then, make your changes to the database.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Access database named Db1.mdb.
  2. In the Database window, click Modules, and then click New. Paste the following code into the module:
    Public Function TestChanges()
        MsgBox "Hello"
    End Function
    					
  3. On the Tools menu, click <database name>Properties, and then click the Protection tab.
  4. Click to select the Lock project for viewing check box, and in the Password and Confirm Password boxes, type red. This password protects the Visual Basic Project in the database.
  5. On the File menu, click Save, and then save the module as Module1. Close Db1.mdb.
  6. Create a second Access database named Db2.mdb. Press ALT+F11 to start the Visual Basic Editor.
  7. On the Tools menu click References. To create a reference to Db1.mdb, click Browse, locate Db1.mdb, and then click OK.
  8. In the Project Explorer window of the Visual Basic Editor, double-click Db1 to expand its tree. When Access asks you for the password, enter the VBE password that you assigned ( red) in step 4.
  9. Locate the module, and view its code. Add the following line of code to the Public Procedure:
    MsgBox "Hello World"
    						
    Note that the Save button on the toolbar is not enabled, nor is the Save command on the File menu.
  10. In the Project Explorer, right-click Db1, and then click <database name> Properties.
  11. In the Properties dialog box, click the Protection tab. Change the password to blue.
  12. Close Db2.mdb. Note that when you close Db2.mdb, you get no error messages that say that the changes will not be saved.
  13. Re-open Db1.mdb, and then click Modules. Select Module1, and then click Design. When Access asks you for the password, type the new password that you created in step 11 ( blue). Note that Access does not accept this password.
  14. Type the original password ( red). Note that the module opens. Note that the changes that you made to the function have not been saved.
This behavior occurs because Access does not save any changes that you make to a referenced project.

Modification Type:MinorLast Reviewed:1/26/2005
Keywords:kbnofix kbprb KB202106