Private Sub Command4_Click()
'full path to the database including name....
Const strDBpath As String = "C:\Users\ziggy\Documents\Database1.mdb"
Dim objAccDB As Object
Set objAccDB = GetObject(strDBpath) 'opens other the other database
objAccDB.Run ("testFunct") 'runs a function in the other database
objAccDB.Quit 'closes the other database after running code
Set objAccDB = Nothing
End Sub
Public Function OpenDatabasePass()
Static AccApp As Access.Application
Const strDBpath As String = "C:\Users\ziggy\Documents\Database1.mdb"
Set AccApp = New Access.Application
AccApp.Visible = True
Dim db As DAO.Database
Set db = AccApp.DBEngine.OpenDatabase(strDBpath, False, False, ";PWD=ziggy")
AccApp.OpenCurrentDatabase strDBpath
' comment out or remove thse lines if you don't want it to close automatically...
'AccApp.CloseCurrentDatabase
AccApp.Quit
db.Close
Set db = Nothing
End Function