DAO Object
 
Opens a specified database and returns a reference to the Database object that represents it.
 

Syntax

expression .OpenDatabase(NameOptionsReadOnlyConnect)
expression A variable that represents a DBEngine object.
 

Parameters

Name
Required/optional
Data type
Description
Name
Required
String
the name of an existing Microsoft Access database file, or the data source name (DSN) of an ODBC data source. See the Name property for more information about setting this value.
Options
Optional
Variant
Sets various options for the database, as specified in Remarks.
ReadOnly
Optional
Variant
True if you want to open the database with read-only access, or False (default) if you want to open the database with read/write access.
Connect
Optional
Variant
Specifies various connection information, including passwords.
 

Return value

Database
 

Remarks

You can use the following values for the options argument.
Setting
Description
True
Opens the database in exclusive mode.
False
(Default) Opens the database in shared mode.
 
When you open a database, it is automatically added to the Databases collection.
 
Some considerations apply when you use dbname:
 
To close a database, and thus remove the Database object from the Databases collection, use the Close method on the object.
 
 Note
When you access a Microsoft Access database engine-connected ODBC data source, you can improve your application's performance by opening a Database object connected to the ODBC data source, rather than by linking individual TableDef objects to specific tables in the ODBC data source.