I want maximum 30 signs in a textbox?

Nirious

Registered User.
Local time
Today, 19:49
Joined
Jul 31, 2004
Messages
106
I have an unbound textfield that is copied to some other fields and blah blah blah.

Bottem line, how do I restrict the user from entering more than 30 signs in this field. I'm looking for a concrete piece of code, or constraint or something.

Thx for helping,

Nirious :cool:
 
Use the Len() function.

You could put this in the Valadation Rule of the text field in the table...

<Len(31)

Or you put together an If statement with something like that in the AfterUpdate event of the field in the form.
 
Hey ghudson,
It seems you've missed that the box is unbound thus the afterUpdate doesn't fit so well ;)

Nirious, i am not sure what kind of behaviour you were talking about. The validation rule proposal by ghudson works great! Although now you specify the validation rule of the control and not the field. This doesn't lock the textbox from entering the longer sequence, however, when you try to leave the box or retrieve its value, the warning message appears blocking you to continue till you correct the value. If it fits your needs then here we go:
1)specify the textBox1.ValidationRule to be
Len([textBox1].[Text])<31 '(sorry... definetely there's a nicer line)
2)define textBox1.ValidationText to be something less ugly than default message
 
Limiting the number of characters in a text box

Hi misunders2d

You could try to define the value 30 in the Property MaxLength of the TextBox.
Insert the Text box in the form.
Click F4 to see the properties
In the MaxLength property, insert 30
 

Users who are viewing this thread

Back
Top Bottom