What is
the IIf Function?
First of all, the IIF function is short
for the Immediate If function.
The syntax for the IIF function is the
following:
IIf (expression,
truepart, falsepart)
This syntax
accomplishes the following:
IIF the expression equates to true,
then the value in the ‘truepart’ is returned; otherwise the value in the
‘falsepart’ is returned.
To put this into a real life example:
If you added the following to a blank
column in a query, where [Number1] and [Number2] are field names for field that
contain number values.
Result: IIF([Number1]>[Number2],
“higher”, “lower or equals to”).
If the field [Number1] is greater than
the field [Number2], i.e. True, then the word “higher” would be displayed in the
query when it is run (which is the first part or the True section of the IIF
statement). However, if the field [Number1] is equal to or less than field
[Number2], i.e. False, then the words “lower or equal to” would be displayed.
Do you like this tip? Subscribe to my free Newsletter to
receive tips via email.
Click Here to subscribe.
 |