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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open database from other database

Status
Not open for further replies.

Greaser

Technical User
Aug 1, 2001
84
0
0
CA
Hi,
How can I open a database from within another database?
Do I use the OpenDatabase command or the Shell command?
The 2 databases are independent from eachother.
How do I use these commands efficiently?
Thanks,
John
 
Do you mean launch a separate instance of MS Access and open up the other database within it?

If so I'd build a command line containing the relevant MSAccess.exe path, database path and workgroup path and use shell to launch it.

Ed Metcalfe.

Please do not feed the trolls.....
 
Hi Ed2020,
Thanks for your reply.
The database is an instance MS Access 2000.
It is located on the same computer as the other database.
Would the command line look something like this?

Dim RetVal
RetVal = Shell("C:\uoi\mra\mra.mdb", 1)

Thanks again.
Cheers,
John
 
When I use the following code, I get an error message:

Dim retval as Varient
RetVal = Shell("C:\uoi\mra\mra.mdb", 1)

Error message:
"Invalid procedure call or arguement".
John
 
And this ?
CreateObject("WScript.Shell").Run "C:\uoi\mra\mra.mdb"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I think you need to specify the MSAccess.exe filepath too.

Something like this:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" /runtime "V:\Abis\BillingRunTimeFront-End\Live2\BillingRunTimeFront-End.mdb" /wrkgrp "V:\Abis\BillingRunTimeFront-End\_Security2\BSSSECURED.mdw" /user BillU /pwd yellow

Ed Metcalfe

Please do not feed the trolls.....
 
PHV's solution worked like a charm.
Thanks guys.
Cheers,
John
 
You can also open a seperate db from with the Access framework itself. First you need to load the Microsoft DAO library through the Object browser by right clicking in the object browser and selecting References. Then go down until you find Microsoft DAO 3.6 Object Library and check the box. (Note: version 3.6 is what's on my computer, as well as most of the others that I've worked with MS Office 2000 on; it could be different on yours) Click the OK button and the library is loaded. This gives you access to the OpenDatabase Function which allows you to open a DB without having to run another instance of Access.

Example:

Sub Test_Open()
Dim DB As DAO.Database
Set DB = OpenDatabase("DB2.Mdb")
End Sub

However, there is a major caveat here. This only opens a DB for data access; to the best of my knowledge, you won't be able to access the forms, macros and code modules at all utilizing this method. You can access tables and queries of the other DB, as well as run SQL commands on the opened DB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top