Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return datatype of bound field 1

Status
Not open for further replies.

DannyTmoov2

IS-IT--Management
Jan 7, 2003
49
GB
(Apologies for the posting masacre today)

Is there anyway to return the datatype of a bound field in Access97?

I'm looping through each control on a form and need to know if the datatype of the bound field.

Cheers
 
use vartype on a control that has a value. VARTYPE(myControl.value). Make sure you are only including bound controls when you loop( no labels, lines, pictures, etc.)
and here are the constants:

vbEmpty 0 Empty (uninitialized)
vbNull 1 Null (no valid data)
vbInteger 2 Integer
vbLong 3 Long integer
vbSingle 4 Single-precision floating-point number
vbDouble 5 Double-precision floating-point number
vbCurrency 6 Currency value
vbDate 7 Date value
vbString 8 String
vbObject 9 Object
vbError 10 Error value
vbBoolean 11 Boolean value
vbVariant 12 Variant (used only with arrays of variants)
vbDataObject 13 A data access object
vbDecimal 14 Decimal value
vbByte 17 Byte value
vbUserDefinedType 36 Variants that contain user-defined types
vbArray 8192 Array
 
Thanks for the speedy reply, apologies though i didn't explain well enough what i wanted. Is it possible to find the datatype of the database table field the control is bound to? I.e. whether a textbox is bound to a field of type text or memo.

Cheers
 
I think this works. I have a memo field and a text box in this example. I return the name of the field bound to a control. I get the recordset of the form using the recordset property. I get the field using the fields collection, and get its type. 10 for text 12 for memo. These DataTypeEnum constants do not correspond to the VARTYPE constants.
:
Private Sub Form_Current()
Dim rs As DAO.Recordset
Set rs = Me.Recordset
MsgBox rs.Fields(Me.memoTest.ControlSource).Type
MsgBox rs.Fields(Me.strTest.ControlSource).Type
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top