ACC: Validation Rules Evaluate Expressions in Unexpected WaysLast reviewed: May 28, 1997Article ID: Q104972 |
The information in this article applies to:
SYMPTOMSModerate: Requires basic macro, coding, and interoperability skills. Microsoft Access evaluates expressions with logical operators differently than you expect. For example, if you enter zero in a field with the validation rule set to "=true and not true," you may receive the following error message:
The value you entered is prohibited by the validation rule set for this field. CAUSEMicrosoft Access evaluates expressions in parts, and compares each part to the value in the field being validated. The expression "=true and not true" is evaluated as:
Field=True AND Field<>TrueThis results in the error message if you enter zero in the field because the validation fails.
RESOLUTIONUse parentheses in the expression to change the way the expression is evaluated. The correct syntax for the example above is:
=(True AND NOT True)Microsoft Access will interpret this expression as:
Field=(True AND NOT True)Zero is an acceptable value for a field with the above validation rule.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional query words: boolean bitwise math
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |