Home

Opening a Database

 
 

Description

To open a database in the Microsoft Office 12.0 Access Database Engine Library, you can call the OpenCurrentDatabase() method of the Access.Application class. Its syntax is:

Access.Application.OpenCurrentDatabase(filepath, Exclusive, bstrPassword)

The first argument can be the name of the database. If you provide (only) the name of the database, the engine would look for it in the same directory as the application that called it. Otherwise, you should provide the complete path to the database.

Here is an example:

Private Sub cmdOpenDatabase_Click()
    Dim dbApplication As Access.Application
    
    Set dbApplication = CreateObject("Access.Application")
    dbApplication.OpenCurrentDatabase ("Exercise.accdb")
    
    ' Use the database here
    
    Set dbApplication = Nothing
End Sub 
     
 

Home Copyright © 2009-2016, FunctionX, Inc. Next