For example, you want to display the number of boxes checked in a checkbox field, from tables that your form is not based on. Use the Count function in a query expression instead of the DCount function. Use the DCount function when you must count records in a domain from within a code module or macro, or in a calculated control. You can use the IIf function to evaluate an expression and return a value when the expression is true or a value when it is false. The IIf function is most useful within expressions that are in a form or report, rather than in Visual Basic code.
Else statement offers greater versatility.
Truepart Value or expression returned if expression is True. Falsepart Value or expression returned if expression is False. The IIf function always evaluates both the truepart and the falsepart, even though it returns only one value. Because of this, you should watch for undesirable side effects. For example, if evaluating the falsepart results in a division by zero error, an error occurs even when the expression is True.