[AccessD] Select statements to get column definitions?

MartyConnelly martyconnelly at shaw.ca
Sat May 22 13:25:36 CDT 2004


This may save you some time

Public Function GetFieldType(colSchema As ADOX.Column) As String
    ' ----- Return the type of the indicated field as a string.
    On Error GoTo ErrorHandler

    Select Case (colSchema.Type)
        Case adTinyInt, adUnsignedTinyInt, adSmallInt, adUnsignedSmallInt
            GetFieldType = "Integer"
        Case adInteger, adUnsignedInt, adBigInt, adUnsignedBigInt
            ' ----- Long integer fields may auto-increment.
            If (CBool(colSchema.Properties("AutoIncrement")) = True) Then
                GetFieldType = "AutoNumber"
            Else
                GetFieldType = "Long Integer"
            End If
        Case adSingle
            GetFieldType = "Single"
        Case adDouble
            GetFieldType = "Double"
        Case adCurrency
            GetFieldType = "Currency"
        Case adDecimal
            GetFieldType = "Decimal"
        Case adNumeric
            GetFieldType = "Numeric"
        Case adBoolean
            GetFieldType = "Yes/No"
        Case adUserDefined, adVariant, adBSTR
            GetFieldType = "Other"
        Case adGUID
            GetFieldType = "GUID"
        Case adDate, adDBDate, adDBTime, adDBTimeStamp
            GetFieldType = "Date/Time"
        Case adChar, adVarChar, adWChar, adVarWChar
            ' ----- For text fields, determine the length as well.
            GetFieldType = "Text(" & colSchema.DefinedSize & ")"
        Case adLongVarChar, adLongVarWChar
            GetFieldType = "Memo"
        Case adBinary, adVarBinary, adLongVarBinary
            GetFieldType = "Binary"
        Case Else
            GetFieldType = "Unknown"
    End Select
    Exit Function

ErrorHandler:
    ' ----- Something is wrong with this entry.
    GetFieldType = "Unknown"
    Exit Function
End Function

Arthur Fuller wrote:

>Stupid me. I forgot about ADOX! Thanks!
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly
>Sent: Saturday, May 22, 2004 1:50 PM
>To: Access Developers discussion and problem solving
>Subject: Re: [AccessD] Select statements to get column definitions?
>
>
>It is all available through ADOX schemas.
>I may have some code lying around
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list