0x450
0x450

Reputation: 252

Validation rules in access

I recently started learning and using microsoft access. However, I am afraid that there is something really bothering me. It's connected with the validation rules. So here is my problem:

I had to validate a field so that only letters could be written. Of course I googled it and found the proper syntax. (Is Null or Not Like "*[!a-z]*")

At first I tried with (Is Null or Like "*[a-z]*"), which I think should be the same as the above one. It's checking every symbol from the string whether it is between 'a'and 'z' and that is why it is used with the obelisk * symbols from the both sides. Am I right?

My question is: Why is the second one not working, although it is a double negative equivalent to the first one. Will be happy for any explanation. Thanks in advance!

P.S Sorry if the question seems useless for you but I really do want to figure out where I am mistaking.

Upvotes: 2

Views: 487

Answers (1)

Gord Thompson
Gord Thompson

Reputation: 123419

Consider the string 'a1b'.

Like "*[!a-z]*" will search the string for any character that is not in the range 'a'..'z'. It finds the '1' in the second position and returns True. Therefore, Not Like "*[!a-z]*" returns False.

On the other hand, Like "*[a-z]*" searches the string for any character that is in the range 'a'..'z'. It finds the 'a' in the first position and returns True.

Upvotes: 1

Related Questions