Getting to Know DBEngine
As mentioned, the DBEngine object refers to the Jet Database Engine, which is at the top of the DAO hierarchy. The DBEngine object contains only two collections: Workspaces and Errors. When referring to the current database, you can use the CurrentDB() function discussed in the next section. When referring to any database other than the current database, you must refer to the DBEngine object, as in Listing 14.47.
Listing 14.47 Accessing the Properties of the DBEngine Object
Sub ReferToCurrentDB()
Dim ws As dao.Workspace
Dim db As dao.Database
Set ws = DBEngine(0)
'Point the Database object at a database
'opened in the current workspace
Set db = ws.OpenDatabase(CurrentProject.Path & "\Chap14Ex.mdb")
'Print the version property of the database
Debug.Print db.Version
End Sub
This code creates a Workspace object variable that points at the current workspace. The OpenDatabase method of the Workspace object is then used to open another database. The version of the database is printed by the routine.