Results 1 to 2 of 2

Thread: determine data type - DAO???

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Philippines
    Posts
    49

    Question

    how can i determine the datatype of the field im accessing, im using the
    rs.fields = <string>. What if the data type of the field is not string, i need to
    know so i can convert my <string>

    im using DAO

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Each field in Fields collection has Type property you can check. Here are available Types:
    Code:
    Constant         Description 
    dbBigInt                Big Integer 
    dbBinary                Binary 
    dbBoolean               Boolean 
    dbByte                  Byte 
    dbChar                  Char 
    dbCurrency              Currency 
    dbDate                  Date/Time 
    dbDecimal               Decimal 
    dbDouble                Double 
    dbFloat                 Float 
    dbGUID                  GUID 
    dbInteger               Integer 
    dbLong                  Long 
    dbLongBinary            Long Binary (OLE Object) 
    dbMemo                  Memo 
    dbNumeric               Numeric 
    dbSingle                Single 
    dbText                  Text 
    dbTime                  Time 
    dbTimeStamp             Time Stamp 
    dbVarBinary             VarBinary
    A little example:
    Code:
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Dim i As Integer
        
        Set db = Workspaces(0).OpenDatabase("C:\MyDB.mdb")
        Set rs = db.OpenRecordset("MyTable", dbOpenSnapshot)
        
        Do Until rs.EOF
            For i = 0 To rs.Fields.Count - 1
                If rs.Fields(i).Type = dbNumeric Then
                    rs.Fields(i)=CInt(<string>)
                End If
            Next
            rs.MoveNext
        Loop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width