Chapter 5: Using Operators and Expressions in Access
185
The return value of the In operator can be negated with Not:
If strCity Not In (“Pittsburgh”, “Philadelphia”) Then
In this case, the body of the If...Then...Else statement executes only if strCity is not set to either
Pittsburgh or Philadelphia.
The Is operator
The Is operator is used only with the keyword Null to determine whether the value of an object
is null:
expression Is Null
The following example uses the Is operator:
[LastName] Is Null Returns True if the LastName field is Null.
It is important to note that the Is operator applies only to objects and object variables, such as
fields in tables. The Is operator can’t be used with simple variables such as strings or numbers.
Operator precedence
When you work with complex expressions that have many operators, Access must determine
which operator to evaluate first, and then which is next, and so forth. Access has a built-in prede-
termined order for mathematical, logical, and Boolean operators, known as operator precedence.
Access always follows this order unless you use parentheses to override its default behavior.
Operations within parentheses are performed before operations outside the parentheses. Within
parentheses, Access follows the default operator precedence.
Precedence is determined first according to category of the operator. The operator rank by order of
precedence is
- Mathematical
- Comparison
- Boolean
Each category contains its own order of precedence, which I explain in the following sections.
The mathematical precedence
Mathematical operators follow this order of precedence:
- Exponentiation
- Negation
- Multiplication and/or division (left to right)