Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    71

    Unanswered: Run Macro in Another DB

    I need to know if it possible to run a macro in one db from a different db and if so how to do it!
    Thanks.

  2. #2
    Join Date
    Apr 2002
    Location
    Illinois
    Posts
    133

    Re: Run Macro in Another DB

    Here's the code. I hope it works for you. Db1 is your db, Db2 contains the macro you want to run:

    Const strPathToDb2 = "<pathname to Db2 directory>"
    Dim strDB As String

    ' Initialize string to database path.
    strDB = strPathToDb2 & "Db2.mdb"
    ' Create new instance of Microsoft Access.
    Set app = CreateObject("Access.Application.8")
    ' Open database in Microsoft Access window.
    app.OpenCurrentDatabase strDB

    ' Run macro.
    app.DoCmd.RunMacro "<macro name>"
    app.CloseCurrentDatabase

    If you want the macro in Db2 to manipulate something in Db2, this should work. If you want it to manipulate something in Db1, I'm not sure how to make that work.
    SteveH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •