See Also Example
Returns one of two parts depending on the evaluation of an expression.
IIf( expr, truepart, falsepart )
The IIf function has the following parts:
expr Expression you want to evaluate.
truepart Value or expression returned if expr is True.
falsepart Value or expression returned if expr is False.
You might use IIf (meaning "Immediate If") to evaluate an expression and return either of two other values. For example, you could use the IIf function to inspect a field on a form and determine whether it is Null . If it is, you might have the function return an empty string; otherwise, it would return the field's contents. The following example checks a field in the copy buffer:
IIf is most useful in the Validate event. The If...Then...Else statement often offers more versatility. IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. For example, if evaluating falsepart results in a division by zero error, an error occurs even if expr is True.