Link to home
Start Free TrialLog in
Avatar of SowleMan
SowleManFlag for United States of America

asked on

How can I determine the number of characters allowed in a text field?

I would like to display the number of characters typed so far and the max number of chars allowed in a text field. I created a function to accomplish  this and I can use this function for any text field. The logic is working well, but the max number of characters is set by a simple VBA assignment before calling the function (("intMaxChars = 30".) I prefer to retrieve this number from the field's definition in the database. How can I accomplish this?
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

you need to refer to the fields size, something like:

intMaxChar = me.recordsetclone.fields("YourTextField").size
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this
intMaxChars = CurrentDb.TableDefs("TableName").Fields("FieldName").Size
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SowleMan

ASKER

Gustav's solution worked immediately. It was exactly what I wanted and needed at that moment.
IrogSinta and Ryan Chong provided good stuff for me to study because I saw new things in their examples.