Microsoft KB Archive/104972: Difference between revisions
m (Text replacement - """ to """) |
m (Text replacement - ">" to ">") |
||
(One intermediate revision by the same user not shown) | |||
Line 67: | Line 67: | ||
Microsoft 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:<br /> | Microsoft 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:<br /> | ||
<pre class="fixed_text"> Field=True AND Field | <pre class="fixed_text"> Field=True AND Field<>True | ||
</pre> | </pre> | ||
<br /> | <br /> |
Latest revision as of 17:43, 20 July 2020
Article ID: 104972
Article Last Modified on 5/6/2003
APPLIES TO
- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition
- Microsoft Access 95 Standard Edition
This article was previously published under Q104972
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
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:
CAUSE
Microsoft 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<>True
This results in the error message if you enter zero in the field because the validation fails.
RESOLUTION
Use 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
- Open a new, blank form in Design view.
Add a text box with the following validation rule to the form:
Text box: Field1 Validation rule: =True and not True
- View the form in Form view.
- Enter a zero in the text box, and then press ENTER. Note that you receive the error message mentioned earlier in this article.
Additional query words: boolean bitwise math
Keywords: kbprb kbusage KB104972