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
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)
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.