Running Access via command line

Treason

#@$%#!
Local time
Today, 04:54
Joined
Mar 12, 2002
Messages
340
I have a VB script to check if the current front-end is the newest version available. If it is not it then it downloads the new front-end. Then it should start the DB.

The only problem is I don't know how to start Access from VB. It needs to start up and join a workgroup with other startup options.. Kinda like a windows shortcut can.

Any ideas on how to make this happen?
 
I'd imagine you'd use a shell command along with this. Does your VB program launch Access and then do other stuff, or do you need to wait for Access to finish before moving on?
 
Typical command line options:

"C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE" /wrkgrp "c:\myworkgroup.mdw" /user "Me" /pwd "my_password" "c:mydatabase.mdb"
 
Those things are all fine but how do I call that from VB?

In VBA It's Call Shell()
 
You use the Shell command in Access [VBA] and VB just the same.

Code:
Call Shell ("C:\Program Files\Microsoft Office\Office\msaccess.exe /wrkgrp X:\YourWorkGroupFile.mdw X:\YourDatabaseFile.mdb /user YourUserName")

Ensure that you remove the internal quotes within the Shell text string. It should look exactly like the target field of the shortcuts properties [except all the quotes].
 
Incorrect. Quotes are required to execute the Shell call to msaccess in this case, due to the spaces in the executable file path. The correct syntax for the above example should be:
Code:
Call Shell ("""C:\Program Files\Microsoft Office\Office\msaccess.exe"" /wrkgrp X:\YourWorkGroupFile.mdw X:\YourDatabaseFile.mdb /user YourUserName")

Alternatively, if you wish to leave all quotes intact, you can, in which case, the statement would read:

Code:
Call Shell ("""C:\Program Files\Microsoft Office\Office\msaccess.exe"" /wrkgrp ""X:\YourWorkGroupFile.mdw"" ""X:\YourDatabaseFile.mdb"" /user ""YourUserName""")
 
I guess both would work [I have not tested your version] but I have been using the below format for Access 97/2003 with Windows XP without any problems.

Code:
Call Shell ("C:\Program Files\Microsoft Office\Office\msaccess.exe /wrkgrp X:\YourWorkGroupFile.mdw X:\YourDatabaseFile.mdb /user YourUserName")
 

Users who are viewing this thread

Back
Top Bottom