Opening a Database as the Current Database and Closing the Current Database : GetObject « Application « VBA / Excel / Access / Word






Opening a Database as the Current Database and Closing the Current Database

 
Sub open()
    Dim myAccess As Access.Application
    Dim myDatabase As Object
    
    Set myAccess = GetObject(, "Access.Application")
    myAccess.CloseCurrentDatabase
    myAccess.OpenCurrentDatabase _
        filepath:="C:\mydb.mdb", Exclusive:=True
    Set myDatabase = myAccess.CurrentDb
End Sub

 








Related examples in the same category

1.Returning an Object with the GetObject Function