IIf() functions can be used any place a function can be used. I do not recommend using them in VBA since they work differently in VBA and can cause unexpected errors. The difference is that in VBA, all parts of the expression are evaluated whether they are true or false so in VBA, the following IIf() would fail with a divide by zero error even though it would work fine in SQL or as an expression in a controlSource:
IIf(MyField = 0, 0, OtherField/MyField)