How to get data type name from the field type enumeration

  • Thread starter Thread starter kiloez
  • Start date Start date
K

kiloez

I am only getting a numerical value for the field type when using VBA to get
the field data types used in a given table, for example:


For Each fld In rst.Fields
FieldType = fld.Type
Next fld

fld.Type returns a numerical value only. How can I get the name instead,
for example: Text, Long Integer, Memo, ect...? Any help would be much
appreciated.
 
kiloez said:
I am only getting a numerical value for the field type when using VBA to
get
the field data types used in a given table, for example:


For Each fld In rst.Fields
FieldType = fld.Type
Next fld

fld.Type returns a numerical value only. How can I get the name instead,
for example: Text, Long Integer, Memo, ect...? Any help would be much
appreciated.

Access has a built-in function for this purpose: TypeName.

Dim i As Long
Debug.Print TypeName(i)

Result: Long
 
Stuart, the TypeName() function returns the subtype for Variants in VBA,
i.e. it gives the names for VarType() values. This is not the same thing as
the field types.

As an example, vbLong = 3, whereas dbLong = 4.
 
Allen Browne said:
Stuart, the TypeName() function returns the subtype for Variants in VBA,
i.e. it gives the names for VarType() values. This is not the same thing
as the field types.

As an example, vbLong = 3, whereas dbLong = 4.

Of course <slaps forehead>. I even made a conversion table some time ago.
Late night posting is my only excuse...
 
Back
Top