Microsoft Access 2010 Bible

(Rick Simeone) #1

Part I: Access Building Blocks


186



  1. Integer division

  2. Modulus division

  3. Addition and/or subtraction (left to right)

  4. String concatenation


The comparison precedence
Comparison operators observe this order of precedence:


  1. Equal

  2. Not equal

  3. Less than

  4. Greater than

  5. Less than or equal to

  6. Greater than or equal to

  7. 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

Free download pdf