Part I: Access Building Blocks
186
- Integer division
- Modulus division
- Addition and/or subtraction (left to right)
- String concatenation
The comparison precedence
Comparison operators observe this order of precedence:
- Equal
- Not equal
- Less than
- Greater than
- Less than or equal to
- Greater than or equal to
- Like
Simple arithmetic provides an example of order of precedence. Remember that Access performs opera-
tions within parentheses before operations that are not in parentheses. Also remember that multiplica-
tion and division operations are performed before addition or subtraction operations.
For example, what is the answer to this simple equation?
x = 10 + 3 * 4
If your answer is 52, you need a better understanding of precedence in Access. If your answer is 22,
you’re right. If your answer is anything else, you need a calculator!
Multiplication is performed before addition by the rules of mathematical precedence. Therefore, the
equation 10 + 3 * 4 is evaluated in this order: 3 * 4 yields 12. Then 12 is added to 10, which returns 22.
Look at what happens when you add parentheses to the equation. What is the answer to this simple
equation?
x = (10 + 3) * 4
Now the answer is 52. Within parentheses, the values 10 and 3 are added first, and then the result (13)
is multiplied by 4, which yields 52.
Precedence order