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
Printable View
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
Each field in Fields collection has Type property you can check. Here are available Types:
A little example: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
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