ACC: Cannot Open a Database with a DoMenuItem Macro

Last reviewed: May 28, 1997
Article ID: Q103187
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0

SYMPTOMS

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

When you try to open another database with a macro containing DoMenuItem and Sendkeys actions, the macro does not seem to run.

CAUSE

Microsoft Access cannot open another database while the DoMenuItem action is running in the current database. Microsoft Access does not support opening multiple databases.

RESOLUTION

To work around this behavior, use either of the following methods. The first method runs a macro from the Database window. The second method runs a macro from a button on a form.

Method 1: Running a Macro from the Database Window

To run a macro from the Database window, follow these steps:

  1. Create a database and create the following macro:

          Macro Name      Action
          ------------------------
          OpenMDB         SendKeys
    
          OpenMDB Actions
          ---------------------------------
          SendKeys
             Keystrokes: %fo<YOURFILE>.MDB~
             Wait: No
    
    

  2. Close and save the macro as OpenMDB.

  3. In the Database window, select the OpenMDB macro, and then click the Run button. Note that the macro closes the current database and opens the database you specify in the OpenMDB macro.

Method 2: Running a Macro from a Form

To run a macro from a form, follow these steps:

  1. Create a database and create the following macro:

          Macro Name       Action
          -----------------------------
          OpenMDB2         SelectObject
                           SendKeys
    
          OpenMDB2 Actions
          ---------------------------------
          SelectObject
             Object Type: Macro
             Object Name: OpenMDB2
             In Database Window: Yes
          SendKeys
             Keystrokes: %fo<YOURFILE>.MDB~
             Wait: No
    
    

  2. Create a blank form and save it as OpenMDBTest.

  3. Add a command button to the form and set the following properties for the control:

          Name: Button1
          Caption: Open Database
    

  4. Set the button's OnClick property to the OpenMDB2 macro.

    NOTE: The OnClick property is called the OnPush property in version 1.x.

  5. Switch the OpenMDBTest form to Form view.

  6. Click the command button to close the current database and open another database.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new database.

  2. Create the following macro:

          Macro Name   Action
          -----------------------
          OpenMe       SendKeys
                       DoMenuItem
    
          OpenMe Actions
          ---------------------------------------------------------
          SendKeys
             NORTHWIND.MDB~  (or NWIND.MDB in versions 1.x and 2.0)
          DoMenuItem
             Menubar: Database
             Menu Name: File
             Command: Open database
    
    

  3. Run the macro. Note that it does not open the Northwind.mdb database.


Additional query words: opendb
Keywords : kbusage McrArg
Version : 1.0 1.1 2.0 7.0
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.