Run different databases

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

Guest

I have macros set up in different databases. Is there a way to run all the
macros from a completely different database?
 
This is what I have so far.
I am able to open the external database, but I do not know how to run macro
in external database.

thank you.

Function Macro_03()
On Error GoTo Macro_03_Err

' WARNINGS OFF
DoCmd.SetWarnings False
' AppMinimize
DoCmd.RunCommand acCmdAppMinimize
' db4.mdb\Macro_02
Call Shell("""C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE"":
""E:\RFQ\test\db4""", 1)
' AppRestore
DoCmd.RunCommand acCmdAppRestore
DoCmd.Quit acSave


Macro_03_Exit:
Exit Function

Macro_03_Err:
MsgBox Error$
Resume Macro_03_Exit

End Function
 
I know of two ways to get access to run code when it is opened. I have been
using .bat files in task scheduler to do this, but maybe as you do the Shell
procedure you can use one of these.

1 - Run a Macro by passing it's name in the command line. This is the text
of the .bat file. It runs a macro I named mac_Update when I run this file.
"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" "C:\Documents and
Settings\Desktop\MyDB.mdb" /x mac_Update

2. Pass a text command in the command line. and use an Autoexec Macro to
read it.
In the batch file I have this line of code.
call "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "C:\Documents
and Settings\Desktop\MyDB.mdb" /cmd "ExportStuff"

In the Autoecec macro I set up a RunCode action that calls a function named
CheckCommandLine ()

the function :
Public Function CheckCommandLine()
' Check value returned by Command function.
Select Case Command
Case "ExportStuff"
DoCmd.OpenQuery........ And the code goes on

Case "BackUpDB"
Code

End Select

I don't know how to directly control another instance of Access, but my
Access Developer's Handndbook (Sybex) has a chapter or two on it.

Hope this helps.
 
Back
Top