Finding out a ListBox values data type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alinagoo
    New Member
    • Apr 2010
    • 53

    #1

    Finding out a ListBox values data type

    Hello all
    I'm working on a database application with MS-Access 2007 and now i have a problem with dynamic report creation process!
    I need to guess the data type of a ListBox! This my problem.
    The ListBox fills dynamically from a selected field of a table(selected by the user).
    I used VarType method to check the data type of a an item of that list box to determine the whole data type but it did not success.
    Please help me to know how can i determine the data type of a ListBox or data type of a table's field.
    More and More thanks
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    alinagoo,
    Here's how you can get the data type of a field returned, if you know the table name and field name:

    Here's a sample ....
    Code:
       
       Dim db As Database, tbl As TableDef, fld As Field
       Set db = CurrentDb
        Dim strType As String
        Dim intType As Integer
     Set tbl = db.TableDefs("tbl_OEShipping")
        Set fld = tbl.Fields("strOrderNumber")
                Debug.Print fld.Name
                strType = fld.Type
                intType = fld.Type
    End Sub
    There's an enumerated list somewhere telling what each value for fld.type means. But you can just run this code for one field of every type and then you can see for yourself what they mean.

    Comment

    • alinagoo
      New Member
      • Apr 2010
      • 53

      #3
      Originally posted by jimatqsi
      alinagoo,
      Here's how you can get the data type of a field returned, if you know the table name and field name:

      Here's a sample ....
      Code:
         
         Dim db As Database, tbl As TableDef, fld As Field
         Set db = CurrentDb
          Dim strType As String
          Dim intType As Integer
       Set tbl = db.TableDefs("tbl_OEShipping")
          Set fld = tbl.Fields("strOrderNumber")
                  Debug.Print fld.Name
                  strType = fld.Type
                  intType = fld.Type
      End Sub
      There's an enumerated list somewhere telling what each value for fld.type means. But you can just run this code for one field of every type and then you can see for yourself what they mean.
      Thanks you are right!
      Good Luck :-bd

      Comment

      Working...