This post is also available in: 日本語 (Japanese)
When writing IIF function nested code in Access VBA, I often forget it, so write it instead of a memo.
The definition of the IIF function is as follows.
If [Condition] is mutch, [Return Value in case of True] is returned. If not, [Return Value in case of False] is returned.
IIf( [Condition], [Return Value in case of True] , [Return Value in case of False] )
For example, when calculating the total value of values that match multiple conditions of IIf, it will look like the sample code below.
If [Condition A] is match and [Condition B] is match, [Return Value in case of True] is returned, and the total value of [Return Value in case of True] is calculated.
Sum(IIf([Condition A], IIf([Condition B], [Return Value in case of True])))
Of course, multiple conditions can be combined in the same way.
The Switch function is useful when you want to perform True/False judgment by picking up specific conditions.