contents.gifindex.gif

Or Operator

Purpose

Used to perform a logical disjunction on two expressions.

Syntax

result = expr1 Or expr2

Notes

If either or both expressions evaluate true (nonzero), result is True (-1). The following table illustrates how result is determined.

If expr1 is
And expr2 is
result is


true (nonzero)
true
True (-1)
true
false (0)
True
true
Null
True
false
true
True
false
false
False (0)
false
Null
Null
Null
true
True
Null
false
Null
Null
Null
Null
The Or 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
1
1
0
1
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 = 11, the left expression is True and the right expression is False. Because at least one comparison expression is True, the Or expression evaluates True.

If A > B Or B > C Then

Debug.Print "One or both comparison expressions are True."

Else

Debug.Print "Both comparison expressions are False."

End If