Length of Text Field

W

Winter Special

Is there any way to determine the length of a text field in VBA?

I'm not talking about the Len() command which returns the length of the
VALUE of the field, I'm talking about the FIELD SIZE which is in the table
definition.
 
B

Brendan Reynolds

Public Sub TestFieldSize()

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb
Set tdf = db.TableDefs("tblTest")
Set fld = tdf.Fields("TestText")
Debug.Print fld.Size

End Sub
 
D

Douglas J Steele

Assuming you've got a reference set to DAO, you can use:

CurrentDb().TableDefs("TableName").Fields("FieldName").Size

For numeric fields, it indicates the number of bytes the field uses.
 
Top