Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/100148

From BetaArchive Wiki
Knowledge Base


ACC: OpenDatabase and CloseDatabase Pseudo Actions

Article ID: 100148

Article Last Modified on 1/18/2007



APPLIES TO

  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition



This article was previously published under Q100148

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

Microsoft Access includes two "pseudo actions," or dynamic data exchange (DDE) commands, called OpenDatabase and CloseDatabase. These commands are available through the DDE SYSTEM topic, and allow you to open and close Microsoft Access databases over a DDE channel.

MORE INFORMATION

The syntax for the OpenDatabase and CloseDatabase pseudo actions is

   OpenDatabase <Database_Location>

   CloseDatabase
                


where <Database_Location> is the path and filename of the Microsoft Access database to be opened. The CloseDatabase action does not take a parameter since Microsoft Access can have only one database open at a time.

The following sample Microsoft Excel macro demonstrates how the OpenDatabase and CloseDatabase pseudo actions work.

NOTE: This macro will not work with Microsoft Access version 1.0.

  1. Start Microsoft Access (Microsoft Access must already be running in order for this macro to work).
  2. In Microsoft Excel, open a new Excel 4.0 macro sheet. Enter the following macro:

          Cell    Command
          -------------------------------------------------
          A1      PseudoOpenCloseDDEExample
          A2
          A3      chan=INITIATE("MSACCESS","SYSTEM")
          A4      =APP.ACTIVATE("Microsoft Access",FALSE)
          A5      =EXECUTE(chan,"[opendatabase northwind.mdb]")
    
          NOTE: In versions 1.1 and 2.0, use =EXECUTE(chan,"[opendatabase
          nwind.mdb]")
    
          A6      =EXECUTE(chan,"[Sample AutoExec]")
          A7      =EXECUTE(chan,"[closedatabase]")
          A8      =TERMINATE(chan)
          A9      =APP.ACTIVATE(,FALSE)
          A10     =RETURN()
                            
  3. Select cell A3. On the Macro menu, click Run, and then click OK.

The commands in cells A3 and A4 initiate a DDE channel to Microsoft Access on the SYSTEM topic and activate the Microsoft Access application.

The command in cell A5 opens the sample database Northwind.mmdb (or NWIND.MDB in version 1.1 and 2.0) in the current working folder (directory), using the OpenDatabase pseudo action.

The command in cell A6 runs the "Sample AutoExec" macro in the Northwind.mdb.

The command in cell A7 closes the currently opened database file using the CloseDatabase pseudo action.

The commands in cells A8-A10 terminate the DDE channel, activate the Microsoft Excel application, and end the macro.

For more information about Using Microsoft Access as a DDE Server, search the Help Index for "servers, DDE," or ask the Microsoft Access 97 Office Assistant.


Additional query words: ole/dde server

Keywords: kbinfo kbinterop KB100148