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.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.