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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I setup an alphanumeric validation rule

Status
Not open for further replies.

MikeydJR

Technical User
Sep 10, 2003
8
US
I'm using access 2002, and I need to set a validation rule in a table so that the only charcters allowed in the text field are:
a-z (case-insensitive)
0-9
these characters + "
and spaces.

Anything else will return an error.
Not quite sure how to set this.
TIA
 
I don't think you'll be able to specifically do this in a table-bound input mask. The mask placeholder character 'a' specifies ANY letter or digit, so ~!@#$%^&*()_+`-=[]\{}|;':&quot;,./<>? are all allowable - there's no discrete way to say the only allowable non-digit, non-alphabet characters are the plus sign, the double quote, and the space.

You may need to set a small proc that looks at the data and evaluates it for any of the non-allowed characters.

Jim



If at first you don't succeed, skydiving probably isn't for you!
Another free Access forum:
More Access stuff at
 
You can test for certain values using the Validation Rule but it won't cover the bases the way you need. For example you can put
Between Chr(48) and Chr(57)
(0 - 9)
on the validation rule line and if you type in
A123 it will fire an input error message saying the rule has been violated but if you type in
1AW3, the validation rule doesn't pick up on the problem. So in a nutshell, Jim's right. You would have to use the Before Update event to call a Function that would check the Chr(*) value for each character in the field and make sure it conformed. If it didn't, you could insert an error message. If you need help with the function, let us know.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top