none
Is there a way to do this with fewer code lines RRS feed

  • Question

  • Hi,

    If not has someone made it do DAO ?  Please...

    Public Function ADO_FIELD_TYPE_NAME(TIPO As Integer) As String
     Select Case TIPO
      Case ADODB.DataTypeEnum.adArray
       ADO_FIELD_TYPE_NAME = "adArray"
      Case ADODB.DataTypeEnum.adBigInt
       ADO_FIELD_TYPE_NAME = "adBigInt"
      Case ADODB.DataTypeEnum.adBinary
       ADO_FIELD_TYPE_NAME = "adBinary"
      Case ADODB.DataTypeEnum.adBoolean
       ADO_FIELD_TYPE_NAME = "adBoolean"
      Case ADODB.DataTypeEnum.adBSTR
       ADO_FIELD_TYPE_NAME = "adBSTR"
      Case ADODB.DataTypeEnum.adChapter
       ADO_FIELD_TYPE_NAME = "adChapter"
      Case ADODB.DataTypeEnum.adChar
       ADO_FIELD_TYPE_NAME = "adChar"
      Case ADODB.DataTypeEnum.adCurrency
       ADO_FIELD_TYPE_NAME = "adCurrency"
      Case ADODB.DataTypeEnum.adDate
       ADO_FIELD_TYPE_NAME = "adDate"
      Case ADODB.DataTypeEnum.adDBDate
       ADO_FIELD_TYPE_NAME = "adDBDate"
      Case ADODB.DataTypeEnum.adDBTime
       ADO_FIELD_TYPE_NAME = "adDBTime"
      Case ADODB.DataTypeEnum.adDBTimeStamp
       ADO_FIELD_TYPE_NAME = "adDBTimeStamp"
      Case ADODB.DataTypeEnum.adDecimal
       ADO_FIELD_TYPE_NAME = "adDecimal"
      Case ADODB.DataTypeEnum.adDouble
       ADO_FIELD_TYPE_NAME = "adDouble"
      Case ADODB.DataTypeEnum.adEmpty
       ADO_FIELD_TYPE_NAME = "adEmpty"
      Case ADODB.DataTypeEnum.adError
       ADO_FIELD_TYPE_NAME = "adError"
      Case ADODB.DataTypeEnum.adFileTime
       ADO_FIELD_TYPE_NAME = "adFileTime"
      Case ADODB.DataTypeEnum.adGUID
       ADO_FIELD_TYPE_NAME = "adGUID"
      Case ADODB.DataTypeEnum.adIDispatch
       ADO_FIELD_TYPE_NAME = "adIDispatch"
      Case ADODB.DataTypeEnum.adInteger
       ADO_FIELD_TYPE_NAME = "adInteger"
      Case ADODB.DataTypeEnum.adIUnknown
       ADO_FIELD_TYPE_NAME = "adIUnknown"
      Case ADODB.DataTypeEnum.adLongVarBinary
       ADO_FIELD_TYPE_NAME = "adLongVarBinary"
      Case ADODB.DataTypeEnum.adLongVarChar
       ADO_FIELD_TYPE_NAME = "adLongVarChar"
      Case ADODB.DataTypeEnum.adLongVarWChar
       ADO_FIELD_TYPE_NAME = "adLongVarWChar"
      Case ADODB.DataTypeEnum.adNumeric
       ADO_FIELD_TYPE_NAME = "adNumeric"
      Case ADODB.DataTypeEnum.adPropVariant
       ADO_FIELD_TYPE_NAME = "adPropVariant"
      Case ADODB.DataTypeEnum.adSingle
       ADO_FIELD_TYPE_NAME = "adSingle"
      Case ADODB.DataTypeEnum.adSmallInt
       ADO_FIELD_TYPE_NAME = "adSmallInt"
      Case ADODB.DataTypeEnum.adTinyInt
       ADO_FIELD_TYPE_NAME = "adTinyInt"
      Case ADODB.DataTypeEnum.adUnsignedBigInt
       ADO_FIELD_TYPE_NAME = "adUnsignedBigInt"
      Case ADODB.DataTypeEnum.adUnsignedInt
       ADO_FIELD_TYPE_NAME = "adUnsignedInt"
      Case ADODB.DataTypeEnum.adUnsignedSmallInt
       ADO_FIELD_TYPE_NAME = "adUnsignedSmallInt"
      Case ADODB.DataTypeEnum.adUnsignedTinyInt
       ADO_FIELD_TYPE_NAME = "adUnsignedTinyInt"
      Case ADODB.DataTypeEnum.adUserDefined
       ADO_FIELD_TYPE_NAME = "adUserDefined"
      Case ADODB.DataTypeEnum.adVarBinary
       ADO_FIELD_TYPE_NAME = "adVarBinary"
      Case ADODB.DataTypeEnum.adVarChar
       ADO_FIELD_TYPE_NAME = "adVarChar"
      Case ADODB.DataTypeEnum.adVariant
       ADO_FIELD_TYPE_NAME = "adVariant"
      Case ADODB.DataTypeEnum.adVarNumeric
       ADO_FIELD_TYPE_NAME = "adVarNumeric"
      Case ADODB.DataTypeEnum.adVarWChar
       ADO_FIELD_TYPE_NAME = "adVarWChar"
      Case ADODB.DataTypeEnum.adWChar
       ADO_FIELD_TYPE_NAME = "adWChar"
      Case Else
       ADO_FIELD_TYPE_NAME = "dasse"
     End Select
    End Function
    
    

    TIA

    João

     

     

     

    Thursday, December 1, 2011 4:53 PM

Answers

  • Shorter but wider...

    Public Function ADO_FIELD_TYPE_NAME(ByRef TIPO As Long) As String
    'Jim Cone - Portland, Oregon USA
     Dim vNums As Variant
     Dim vText As Variant

     vNums = Array(0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 64, 72, _
         128, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 200, 201, 202, 203, 204, 205, 8192)
     vText = Array(vbNullString, "adEmpty", "adSmallInt", "adInteger", "adSingle", "adDouble", _
        "adCurrency", "adDate", "adBSTR", "adIDispatch", "adError", "adBoolean", "adVariant", _
        "adIUnknown", "adDecimal", "adTinyInt", "adUnsignedTinyInt", "adUnsignedSmallInt", _
        "adUnsignedInt", "adBigInt", "adUnsignedBigInt", "adFileTime", "adGUID", "adBinary", _
        "adChar", "adWChar", "adNumeric", "adUserDefined", "adDBDate", "adDBTime", _
        "adDBTimeStamp", "adChapter", "adPropVariant", "adVarNumeric", "adVarChar", _
        "adLongVarChar", "adVarWChar", "adLongVarWChar", "adVarBinary", "adLongVarBinary", "AdArray")
          
     ADO_FIELD_TYPE_NAME = vText(Application.WorksheetFunction.Match(TIPO, vNums, 1))
    End Function
    '---
     Jim Cone
     Portland, Oregon USA
     http://www.mediafire.com/PrimitiveSoftware
     (free and commercial excel programs)

    Friday, December 2, 2011 2:49 PM

All replies

  • Hi João,

     

    I don't see how you can shorten it, as you enlisted all the Fieldtypes.

    In below thread you can find the DAO equivelants and fieldtypes:

    http://allenbrowne.com/ser-49.html

     

    Hope this helps,

     


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    Thursday, December 1, 2011 8:10 PM
    Moderator
  • Shorter but wider...

    Public Function ADO_FIELD_TYPE_NAME(ByRef TIPO As Long) As String
    'Jim Cone - Portland, Oregon USA
     Dim vNums As Variant
     Dim vText As Variant

     vNums = Array(0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 64, 72, _
         128, 129, 130, 131, 132, 133, 134, 135, 136, 138, 139, 200, 201, 202, 203, 204, 205, 8192)
     vText = Array(vbNullString, "adEmpty", "adSmallInt", "adInteger", "adSingle", "adDouble", _
        "adCurrency", "adDate", "adBSTR", "adIDispatch", "adError", "adBoolean", "adVariant", _
        "adIUnknown", "adDecimal", "adTinyInt", "adUnsignedTinyInt", "adUnsignedSmallInt", _
        "adUnsignedInt", "adBigInt", "adUnsignedBigInt", "adFileTime", "adGUID", "adBinary", _
        "adChar", "adWChar", "adNumeric", "adUserDefined", "adDBDate", "adDBTime", _
        "adDBTimeStamp", "adChapter", "adPropVariant", "adVarNumeric", "adVarChar", _
        "adLongVarChar", "adVarWChar", "adLongVarWChar", "adVarBinary", "adLongVarBinary", "AdArray")
          
     ADO_FIELD_TYPE_NAME = vText(Application.WorksheetFunction.Match(TIPO, vNums, 1))
    End Function
    '---
     Jim Cone
     Portland, Oregon USA
     http://www.mediafire.com/PrimitiveSoftware
     (free and commercial excel programs)

    Friday, December 2, 2011 2:49 PM
  • Jim,

    I was writing in access, but because I'vd post in a VBA forum you are the winner.... :)

    Thanks

     

    Tuesday, December 13, 2011 7:59 PM