Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Length Edit

Status
Not open for further replies.

FredSB

Programmer
Nov 20, 2002
11
US
How would I check to make sure that the user enters the correct number of chararacters in a field? This is a Access database. Say that the field is 4 characters long and the user enters 3 chararacters and then hits the tab key to exit out of the field. I would like to display an error that says that the wrong number of characters was entered.
 
Hi!

In the before update event you would use:

If Len(Me!YourTextBox.Text) <> 4 Then
Call MsgBox(YourMessage)
Cancel = -1
End If

hth


Jeff Bridgham
bridgham@purdue.edu
 
An alternative to using code is to just set the Validation Rule and Validation Text properties for your field.

-Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top