Results 1 to 5 of 5
  1. #1
    bwelton is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    2

    Puzzling validation rule for text only

    Hi

    I'm confused about the Access validation rule for text only fields. All the support states to use:



    Not Like "*[!a-z]*"

    This is difficult for the students I teach to understand.

    I tried to teach them:

    Like "*[a-z]*"

    instead, which should be logically equivalent and easier to grasp. However, this does not work for a mixture of letters and numbers i.e. Jo6n. The first version of the rule does catch this and correctly reports an error. But why is this so?

    Thanks
    Bryan

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Can you explain what the following is accomplishing and where it is applied?
    Not Like "*[!a-z]*"

    I am having difficulty placing it anywhere specific and understanding its function.

  3. #3
    bwelton is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2015
    Posts
    2
    It's a validation rule for a field in a table. It's used to ensure that there can be no numbers or symbols in a forename, surname field etc.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    OK, thanks. As a constraint at the table level, Not Like "*[!a-z]*", is probably the only way to go.

    I will be perfectly honest and say that I have not used the brackets and the bang together like that before. But, if your question is about a simple way to do it and the confusion about using the Not operator. I don't see a way around it.

    I find that expressions can be difficult to understand if they are not used within a statement. So using an If Then Else statement might help teach others about how the Not operator can replace = False.
    Last edited by ItsMe; 12-03-2015 at 09:04 AM. Reason: Removed my previous edit

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I did some testing and, as a result, removed my edit from post #4. What I found is that the expression in quotes is evaluated separately. So if the rule is to not have any numbers, you need to evaluate each char using the bang. Then, evaluate each result using the Not operator. In other words, the only way to ensure the rule that no char is numeric, you need both the ! and the Not operators. Otherwise, a combination of numeric and alpha chars will be allowed.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  2. Replies: 2
    Last Post: 12-27-2013, 07:32 AM
  3. Validation Rule
    By WayneSteenkamp in forum Access
    Replies: 7
    Last Post: 03-01-2012, 04:22 AM
  4. Help with validation rule
    By Desstro in forum Programming
    Replies: 5
    Last Post: 02-27-2011, 08:05 PM
  5. Validation rule for a text field
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 03-14-2006, 11:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums