The OpenDatabase() FunctionWhen you declare a database variable, you must specify the OpenDatabase() function to open the selected database. Remember that a database contains many tables. Before you can access one of the tables, you must open the database. The OpenDatabase() function informs Visual Basic that you want to access the database. The following code declares a database variable and opens a database: Dim dbBooks As Database Set dbBooks = OpenDatabase("Biblio.mdb") After OpenDatabase() completes its task, Visual Basic has prepared the database and connected the database file to your Database data-typed variable. The Set command works almost like an assignment statement. Set is used to create a reference to an object. The dbBooks variable can't really hold the entire database, but dbBooks is a reference to the database.
The OpenDatabase() function opens both ODBC databases and Jet engine databases. A Jet engine database is a Microsoft-designed database specification that provides quick access to databases. The database can reside in any folder and on any computer networked to yours. |
|
![]() |
![]() |
|||