contents.gifindex.gifprev1.gifnext1.gif

And Operator

Purpose

Used to perform a logical conjunction on two expressions.

Syntax

result = expr1 And expr2

Notes

If and only if both expressions evaluate true (nonzero), result is True (-1). If either expression evaluates false (0), result is False (0). The following table illustrates how result is determined.

If expr1 is
And expr2 is
result is


true (nonzero)
true
True (-1)
true
false (0)
False (0)
true
Null
Null
false
true
False
false
false
False
false
Null
False
Null
true
Null
Null
false
False
Null
Null
Null


The And operator also performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following truth table.

If bit in expr1 is
And bit in expr2 is
result is


0
0
0
0
1
0
1
0
0
1
1
1


Bit-wise comparisons can be performed only in Access Basic.

Example

This example prints a message that depends on the value of variables A, B, and C, assuming that no variable is a Null. If A = 10, B = 8, and C = 6, both expressions evaluate True. Because both expressions are True, the And expression is also True.

If A > B And B > C Then

Debug.Print "Both expressions are True."

Else

Debug.Print "One or both expressions are False."

End If