I have some code here that works fine as far as opening up a second database. The problem I seem to be running into now is when I close the original Db, the new database I just opened closes too.
Any ideas out there on how I might add some code to this? My goal is to have this code in a form and when ran from the Current Db, it would open a 2nd database then close the current.
*****Begin Code*****
Option Compare Database
Public Function OpenDB()
Dim DB
Dim strDbName
Dim strPassword
strDbName = "c:\File_Path"
strPassword = "MyPassword"
Static acc As Access.Application
Set acc = CreateObject("Access.Application")
acc.Visible = True
Set DB = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=" & strPassword)
acc.OpenCurrentDatabase strDbName
End Function
*****End Code*****
JB
Any ideas out there on how I might add some code to this? My goal is to have this code in a form and when ran from the Current Db, it would open a 2nd database then close the current.
*****Begin Code*****
Option Compare Database
Public Function OpenDB()
Dim DB
Dim strDbName
Dim strPassword
strDbName = "c:\File_Path"
strPassword = "MyPassword"
Static acc As Access.Application
Set acc = CreateObject("Access.Application")
acc.Visible = True
Set DB = acc.DBEngine.OpenDatabase(strDbName, False, False, ";PWD=" & strPassword)
acc.OpenCurrentDatabase strDbName
End Function
*****End Code*****
JB