Text Field Validation

gselliott

Registered User.
Local time
Today, 22:21
Joined
May 17, 2002
Messages
106
This is probably really easy but i am having trouble finding any posts with the answer.

What i am wanting to do is to display an error message when the user tries to enter more than 30 characters into a text field. i have restricted the field size in the table to 30 which stops them entering more than 30 characters but i would like to display a message when they have reached the limit.

Thanks in advance!
 
In the KeyPress event of your textbox, put this code (changing the textbox name and message where necessary):

Code:
If Len(txtMyTextBoxName)>30 then
KeyCode = 0
MsgBox "Sorry you cannot enter anymore characters - 30 is the limit", vbOK ,"Length Notification"
End If

This code would restrict the text box to 30 characters, even without a validation on the table field.
 
Thanks for that i will give that a go.
 

Users who are viewing this thread

Back
Top Bottom