Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Access Database from current database 1

Status
Not open for further replies.

paullem

Programmer
Jan 21, 2005
80
GB
Hi,

I'm trying to run an access database from the database already open. The idea is that the user will select the database from a menu option, the new database will open and the current one will close. I've tried using the shell command: shell("C:\Program Files\Microsoft Office\Office11\msaccess.exe" "c:\TestSelect1\Test0910.mde",vbMaximizedFocus) but this keeps failing with the error message: Compile error: Expected list separator

Many thanks for any help,


 
Hi,

Answered my own question using:
Call Shell("C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe C:\TestSelect1\Test0910.mde", 1)


 
Just a little other code which would do the same thing but would not require you to know where the Access installation is. If someone installed to a custom path then your code would fail.

Code:
Dim objAcc As Object

Set objAcc = CreateObject("Access.Application")

objAcc.OpenCurrentDatabase("C:\TestSelect1\Test0910.mde")
objAcc.UserControl = True

Set objAcc = Nothing
Yes, it is a little more code but it doesn't require the path to the executable, as does the other.

Bob Larson
FORMER Microsoft Access MVP (2008-2009, 2009-2010)
Free Tutorials/Samples/Tools:
 
Good Idea

Never give up never give in.

There are no short cuts to anything worth doing :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top