Type Property Example (Property) (VB)
This example demonstrates the Type property. It is a model of a utility for listing the names and types of a collection, like Properties, Fields, etc.
We do not need to open the Recordset to access its Properties collection; they come into existence when the Recordset object is instantiated. However, setting the CursorLocation property to adUseClient adds several dynamic properties to the Recordset object's Properties collection, making the example a little more interesting. For sake of illustration, we explicitly use the Item property to access each Property object.
Public Sub Main()
TypeX
End Sub
Public Sub TypeX()
Dim rst As ADODB.Recordset
Dim prop As ADODB.Property
Dim ix As Integer
Dim strMsg As String
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
For ix = 0 To rst.Properties.Count - 1
Set prop = rst.Properties.Item(ix)
Select Case prop.Type
Case adBigInt
strMsg = "adBigInt"
Case adBinary
strMsg = "adBinary"
Case adBoolean
strMsg = "adBoolean"
Case adBSTR
strMsg = "adBSTR"
Case adChapter
strMsg = "adChapter"
Case adChar
strMsg = "adChar"
Case adCurrency
strMsg = "adCurrency"
Case adDate
strMsg = "adDate"
Case adDBDate
strMsg = "adDBDate"
Case adDBTime
strMsg = "adDBTime"
Case adDBTimeStamp
strMsg = "adDBTimeStamp"
Case adDecimal
strMsg = "adDecimal"
Case adDouble
strMsg = "adDouble"
Case adEmpty
strMsg = "adEmpty"
Case adError
strMsg = "adError"
Case adFileTime
strMsg = "adFileTime"
Case adGUID
strMsg = "adGUID"
Case adIDispatch
strMsg = "adIDispatch"
Case adInteger
strMsg = "adInteger"
Case adIUnknown
strMsg = "adIUnknown"
Case adLongVarBinary
strMsg = "adLongVarBinary"
Case adLongVarChar
strMsg = "adLongVarChar"
Case adLongVarWChar
strMsg = "adLongVarWChar"
Case adNumeric
strMsg = "adNumeric"
Case adPropVariant
strMsg = "adPropVariant"
Case adSingle
strMsg = "adSingle"
Case adSmallInt
strMsg = "adSmallInt"
Case adTinyInt
strMsg = "adTinyInt"
Case adUnsignedBigInt
strMsg = "adUnsignedBigInt"
Case adUnsignedInt
strMsg = "adUnsignedInt"
Case adUnsignedSmallInt
strMsg = "adUnsignedSmallInt"
Case adUnsignedTinyInt
strMsg = "adUnsignedTinyInt"
Case adUserDefined
strMsg = "adUserDefined"
Case adVarBinary
strMsg = "adVarBinary"
Case adVarChar
strMsg = "adVarChar"
Case adVariant
strMsg = "adVariant"
Case adVarNumeric
strMsg = "adVarNumeric"
Case adVarWChar
strMsg = "adVarWChar"
Case adWChar
strMsg = "adWChar"
Case Else
strMsg = "*UNKNOWN*"
End Select
Debug.Print "Property " & ix & ": " & prop.Name & _
", Type = " & strMsg
Next ix
End Sub