This example demonstrates the Type property by returning the name of the constant corresponding to the value of the Type property of four different Recordsets. The RecordsetType function is required for this procedure to run.
Sub TypeX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' Default is dbOpenTable.
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees")
Debug.Print _
"Table-type recordset (Employees table): " & _
RecordsetType(rstEmployees.Type)
rstEmployees.Close
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees", _
dbOpenDynaset)
Debug.Print _
"Dynaset-type recordset (Employees table): " & _
RecordsetType(rstEmployees.Type)
rstEmployees.Close
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees", _
dbOpenSnapshot)
Debug.Print _
"Snapshot-type recordset (Employees table): " & _
RecordsetType(rstEmployees.Type)
rstEmployees.Close
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees", _
dbOpenForwardOnly)
Debug.Print _
"Forward-only-type recordset (Employees table): " & _
RecordsetType(rstEmployees.Type)
rstEmployees.Close
dbsNorthwind.Close
End Sub
Function RecordsetType(intType As Integer) As String
Select Case intType
Case dbOpenTable
RecordsetType = "dbOpenTable"
Case dbOpenDynaset
RecordsetType = "dbOpenDynaset"
Case dbOpenSnapshot
RecordsetType = "dbOpenSnapshot"
Case dbOpenForwardOnly
RecordsetType = "dbOpenForwardOnly"
End Select
End Function
This example demonstrates the Type property by returning the name of the constant corresponding to the value of the Type property of all the Field objects in the Employees table. The FieldType function is required for this procedure to run.
Sub TypeX2()
Dim dbsNorthwind As Database
Dim fldLoop As Field
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Debug.Print "Fields in Employees TableDef:"
Debug.Print " Type - Name"
' Enumerate Fields collection of Employees table.
For Each fldLoop In _
dbsNorthwind.TableDefs!Employees.Fields
Debug.Print " " & FieldType(fldLoop.Type) & _
" - " & fldLoop.Name
Next fldLoop
dbsNorthwind.Close
End Sub
Function FieldType(intType As Integer) As String
Select Case intType
Case dbBoolean
FieldType = "dbBoolean"
Case dbByte
FieldType = "dbByte"
Case dbInteger
FieldType = "dbInteger"
Case dbLong
FieldType = "dbLong"
Case dbCurrency
FieldType = "dbCurrency"
Case dbSingle
FieldType = "dbSingle"
Case dbDouble
FieldType = "dbDouble"
Case dbDate
FieldType = "dbDate"
Case dbText
FieldType = "dbText"
Case dbLongBinary
FieldType = "dbLongBinary"
Case dbMemo
FieldType = "dbMemo"
Case dbGUID
FieldType = "dbGUID"
End Select
End Function
This example demonstrates the Type property by returning the name of the constant corresponding to the value of the Type property of all the QueryDef objects in Northwind. The QueryDefType function is required for this procedure to run.
Sub TypeX3()
Dim dbsNorthwind As Database
Dim qdfLoop As QueryDef
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Debug.Print "QueryDefs in Northwind Database:"
Debug.Print " Type - Name"
' Enumerate QueryDefs collection of Northwind database.
For Each qdfLoop In dbsNorthwind.QueryDefs
Debug.Print " " & _
QueryDefType(qdfLoop.Type) & " - " & qdfLoop.Name
Next qdfLoop
dbsNorthwind.Close
End Sub
Function QueryDefType(intType As Integer) As String
Select Case intType
Case dbQSelect
QueryDefType = "dbQSelect"
Case dbQAction
QueryDefType = "dbQAction"
Case dbQCrosstab
QueryDefType = "dbQCrosstab"
Case dbQDelete
QueryDefType = "dbQDelete"
Case dbQUpdate
QueryDefType = "dbQUpdate"
Case dbQAppend
QueryDefType = "dbQAppend"
Case dbQMakeTable
QueryDefType = "dbQMakeTable"
Case dbQDDL
QueryDefType = "dbQDDL"
Case dbQSQLPassThrough
QueryDefType = "dbQSQLPassThrough"
Case dbQSetOperation
QueryDefType = "dbQSetOperation"
Case dbQSPTBulk
QueryDefType = "dbQSPTBulk"
End Select
End Function