The DBEngine Object

The DBEngine object contains both Microsoft Jet and ODBCDirect workspaces. The DefaultType property of the DBEngine object determines what type of Workspace object is created by default when you use the CreateWorkspace method. If you set the DefaultType property to dbUseODBC, then the default workspace is an ODBCDirect workspace. When you’re creating a workspace, you can override the setting for this property by specifying either dbUseJet or dbUseODBC as the type argument of the CreateWorkspace method. For example, if the DefaultType property is set to dbUseJet and you want to create an ODBCDirect workspace, specify the dbUseODBC constant as the type argument of the CreateWorkspace method. Conversely, if the DefaultType property is set to dbUseODBC and you want to create a Microsoft Jet workspace, specify the dbUseJet constant as the type argument of the CreateWorkspace method.

Note If you’re programming in Microsoft Access, be careful about setting the DefaultType property to dbUseODBC. Because Microsoft Access uses DAO and Microsoft Jet for many types of operations, setting the DefaultType property to dbUseODBC may cause unexpected results.

The following code creates an ODBCDirect workspace.

Dim wrkODBC As Workspace
Set wrkODBC = DBEngine.CreateWorkspace("NewODBCWrk", "Admin", "", dbUseODBC)

Because you can use both Microsoft Jet and ODBCDirect workspaces in your code, you may need to determine the type of a Workspace object after it is created. You can do this by using the Type property of the Workspace object. The Type property is read-only once it is set and returns either dbUseJet or dbUseODBC.