Part I: Access Building Blocks
176
The tricky thing about modulo division is that the returned value is the remainder after integer
division is performed on the operands. The Mod operator is often used to determine whether a
number is even or odd by performing modulo division with 2 as the divisor:
5 Mod 2 = 1
4 Mod 2 = 0
If Mod returns 1 , the dividend is odd. Mod returns 0 when the dividend is even.
Comparison operators
Comparison operators compare two values or expressions in an equation. There are six basic com-
parison operators:
= Equal
<> Not equal
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
The expressions built from comparison operators always return True, False, or Null. Null is
returned when the expression can’t be evaluated.
As you read the following descriptions, please keep in mind that Access is case-insensitive in most
situations. When comparing strings, for example, “CAR,” “Car,” and “car” are the same to Access.
Note
Access actually returns a numeric value for comparison operator expressions. Access uses –1 to represent
True and 0 to represent False.
If either side of an equation is a Null value, the result is always Null.
The equal operator: =
The equal operator (=) returns True if the two expressions are the same. For example,
[tblProducts].[Category] = “Car” Returns True if Category is a car. It
returns False for any other Category.
[tblSales].[SaleDate] = Date() Returns True if the date in SaleDate is
today and False for any other date.
The not-equal operator: <>
The not-equal operator (<>) is the opposite of the equal operator. For example,
[tblProducts].[Category] <> “Car” Returns True if Category is
anything but car and False
only when Category is car.