Close and Open DB VBA

joeKra

Registered User.
Local time
Today, 02:39
Joined
Jan 24, 2012
Messages
208
hello,

i am trying to close 1 DB but in the same time it should open Another DB how could i get it work?? i have tried CloseCurrentDatabase but it closes both and i cannot open the 2nd DB if the 1st is already closed, what's the gimmick here?? perhaps i should use a .bat file (which i certainly don't know how to make it:confused:)
any help would be appreciated
 
Here you go - code for in the first database to open the other and then close itself:

Code:
Function OpenOtherDb(strDbPath As String)
  Dim objAcc As Object

   Set objAcc = CreateObject("Access.Application")

   ObjAcc.OpenCurrentDatabase strDbPath

   ObjAcc.UserControl = True
  
   Application.Quit
End Function

That should do it. Just put that code into a standard module but then call it from wherever you need in that first database and pass the path and name of the database you want to open like:

OpenOtherDb "C:\Test\Mydb.accdb"
 
THANKS !!

BOB i dont believe it... you still using Create Object?? is this not for the old timers??
 

Users who are viewing this thread

Back
Top Bottom