Run a Macro from a different database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I run a macro that is attached to another database that is on our
server. Both of our Access database are on the same server but I need to run
a macro and the queries that are attached to that same database. What is the
code I can attach to my button on my other database. Database 1 :(have
button) Database 2: (has macro , queries and tables that I need to run and
access).

How is this done?
 
Create a reference from MDB1 to MDB2, as followed
1. Open MDB2
2. Create a function in a module that call the Macro
Function RunMyMacro()
docmd.RunMacro "MacroName"
End Function
3. Close MDB2
4. Open MDB1
5. Press Ctrl+G to open code editor
6. In the menu bar select Tools > reference
7. Browse and select MDB2
8. Call the function you created in stage 2

RunMyMacro
======================
The reference from MDB1 to MDB2 will recognize all the functions that are in
MDB2 only, it wont recognize Forms/Reports/Macro's etc.
So to run any of them, you'll need to create a function in MDB2 that run any
of them, and then you can run the function.
 
PERFECT! THANK YOU VERY MUCH!

Ofer Cohen said:
Create a reference from MDB1 to MDB2, as followed
1. Open MDB2
2. Create a function in a module that call the Macro
Function RunMyMacro()
docmd.RunMacro "MacroName"
End Function
3. Close MDB2
4. Open MDB1
5. Press Ctrl+G to open code editor
6. In the menu bar select Tools > reference
7. Browse and select MDB2
8. Call the function you created in stage 2

RunMyMacro
======================
The reference from MDB1 to MDB2 will recognize all the functions that are in
MDB2 only, it wont recognize Forms/Reports/Macro's etc.
So to run any of them, you'll need to create a function in MDB2 that run any
of them, and then you can run the function.
 
Back
Top