2nd Instance of Access

  • Thread starter Thread starter Luke Bailey
  • Start date Start date
L

Luke Bailey

Hi,
How do I open another database from a current running
database in Access (ex - I want code in Northwind.mdb to
open up a second database - SAMPLE.MDB)?
 
Sub OpenExistingDataBase(
Dim retVal As Lon
Dim AccPath As Strin
Dim DbPath As Strin

AccPath = "C:\Program Files\Microsoft Office\Office\MSAccess.exe
DbPath = "D:\db1.mdb

retVal = Shell(AccPath & " " & DbPath

End Su
 
Hi Luke

If you want your code to get at stuff in the database you can use
something like this:

Dim wsW As DAO.Workspace
Dim dbD As DAO.Database

Set wsW = dbEngine.CreateWorkspace("Workspace2", "Admin", "")
Set dbD = wsW.Opendatabase("D:\folder\file.mdb")

Or if you want to launch it in a new instance of Access and then leave
the rest to the user, use the VBA Shell() function, something like this:
Shell("msaccess.exe ""D:\folder\SAMPLE.MDB"" ")
 
Perfect! That was exactly what I was looking for. I was
having trouble locating anything in help.
Thanks for your assistance!

Luke
-----Original Message-----
Hi Luke

If you want your code to get at stuff in the database you can use
something like this:

Dim wsW As DAO.Workspace
Dim dbD As DAO.Database

Set wsW = dbEngine.CreateWorkspace ("Workspace2", "Admin", "")
Set dbD = wsW.Opendatabase("D:\folder\file.mdb")

Or if you want to launch it in a new instance of Access and then leave
the rest to the user, use the VBA Shell() function, something like this:
Shell("msaccess.exe ""D:\folder\SAMPLE.MDB"" ")


Hi,
How do I open another database from a current running
database in Access (ex - I want code in Northwind.mdb to
open up a second database - SAMPLE.MDB)?

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
.
 
Back
Top