The Databases collection contains all Database objects currently open within a Workspace object. In DAO, a Database object represents a currently open database. This can be a native Microsoft Jet database or an external database. You can have multiple databases open at one time, even databases of different types.
In Visual Basic, after you open a database and return a reference to it by using the OpenDatabase method, you can refer to the database according to its position in the Databases collection. If you open only one database, then you can refer to that database in any of the following ways:
DBEngine.Workspaces(0).Databases(0) DBEngine.Workspaces(0)(0) DBEngine(0)(0)
If you’re working in Microsoft Access 97, you can use either the CurrentDb function or the DBEngine(0)(0) syntax to return a reference to the database that is currently open in the Microsoft Access user interface. The CurrentDb function differs from the DBEngine(0)(0) syntax in that it creates another instance of the current database and returns a reference to that instance, and it refreshes all the collections in the current database. On the other hand, the DBEngine(0)(0) syntax doesn’t refresh any collections, so it may perform faster.
If you switch from using the CurrentDb function to the DBEngine(0)(0) syntax, make sure that your code doesn’t depend on any collections being refreshed. If it does, you can refresh these individual collections separately.
Note If you specify a value for the connect argument of the OpenDatabase method, you must also specify a value for the preceding read-only argument.
Microsoft Access and Visual Basic Users In Microsoft Access versions 1.x and 2.0, several databases are automatically opened when you open your database through the Microsoft Access user interface. These include the various library databases that Microsoft Access uses to perform its own functions. The other databases that Microsoft Access opens are used internally by Microsoft Access and are not part of the Databases collection. In Microsoft Access 97, library databases are identified by references to specific type libraries, but are not actually loaded until needed.
Microsoft Access also creates a default Workspace object when you open a database. The user account that’s currently logged on to the database is the account used to create the default workspace.
In Visual Basic, no databases are open in a workspace until you explicitly open them by using the OpenDatabase method — unless you use the Data control, which automatically opens the appropriate database for you when the form containing the Data control is loaded.