DefaultType Property

Applies To

DBEngine object.

Description

Sets or returns a value that indicates what type of workspace (Microsoft Jet or ODBCDirect) will be used by the next Workspace object created.

Settings And Return Values

The setting or return value is a Long that can be set to either of the following constants.

Constant

Description

dbUseJet

Creates Workspace objects connected to the Microsoft Jet database engine.

dbUseODBC

Creates Workspace objects connected to an ODBC data source.


Remarks

The setting can be overridden for a single Workspace by setting the type argument to the CreateWorkspace method.

Example

This example uses the DefaultType property to predetermine what type of Workspace object will be created when you call the CreateWorkspace method. The TypeOutput function is required for this procedure to run.

Sub DefaultTypeX()

    Dim wrkODBC As Workspace
    Dim wrkJet As Workspace
    Dim prpLoop As Property

    ' Set DefaultType property and create Workspace object
    ' without specifying a type.
    DBEngine.DefaultType = dbUseODBC
    Set wrkODBC = CreateWorkspace("ODBCWorkspace", _
        "admin", "")

    Debug.Print "DBEngine.DefaultType = " & _
        TypeOutput(DBEngine.DefaultType)
    With wrkODBC
        ' Enumerate Properties collection of Workspace object.
        Debug.Print "Properties of " & .Name
        On Error Resume Next
        For Each prpLoop In .Properties
            Debug.Print "    " & prpLoop.Name & " = " & prpLoop
            If prpLoop.Name = "Type" Then Debug.Print _
                "        (" & TypeOutput(prpLoop.Value) & ")"
        Next prpLoop
        On Error GoTo 0
    End With

    ' Set DefaultType property and create Workspace object
    ' without specifying a type.
    DBEngine.DefaultType = dbUseJet
    Set wrkJet = CreateWorkspace("JetWorkspace", "admin", "")

    Debug.Print "DBEngine.DefaultType = " & _
        TypeOutput(DBEngine.DefaultType)
    With wrkJet
        ' Enumerate Properties collection of Workspace object.
        Debug.Print "Properties of " & .Name
        On Error Resume Next
        For Each prpLoop In .Properties
            Debug.Print "    " & prpLoop.Name & " = " & prpLoop
            If prpLoop.Name = "Type" Then Debug.Print _
                "        (" & TypeOutput(prpLoop.Value) & ")"
        Next prpLoop
        On Error GoTo 0
    End With
    wrkODBC.Close
    wrkJet.Close

End Sub

Function TypeOutput(intTemp As Integer) As String

    If intTemp = dbUseJet Then
        TypeOutput = "dbUseJet"
    Else
        TypeOutput = "dbUseODBC"
    End If

End Function