Length of Text Field

  • Thread starter Thread starter Winter Special
  • Start date Start date
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.
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top