Microsoft Access - Conditionally Display Text Strings (Access 97/2000/2002/2003)

You'll often want to customize text according to a variable condition. For instance, if one field's value is greater than or equal to another field's, you may want to return one message; if the value is less, you want to return a different message. You can accomplish this with the IIf() function, which uses the syntax:

  • IIf(expr, truepart, falsepart)

Let's say that a form or report displays fields named Target and Total. You can display a conditional message based on the controls' values by adding another textbox and specifying the following expression as the Control Source:

  • =IIf([Total]>=[Target],"You've met the goal!","Goal not reached.")

You can also use the IIf() function to create field expressions in queries.

Go back