In all documentation and everywhere I've looked on the web, it is clearly stated that:
IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. For example, if evaluating falsepart results in a division by zero error, an error occurs even if expr is True.
I seem to have found one situation where this is either not true, or is treated as a special case that is undocumented.
Dim rs as RecordSet ' Assume this is populated
Dim done as boolean
dim key as long
Do while not done
key = iif(rs.EOF,MAXLONG,rs!id)
...
Loop
(For reasons that don't matter here I can't just write Do while not rs.eof... in the real code it's actually a 2-way merge)
Normally, when a Recordset is at EOF, attempting to refer to a field (i.e. rs!id) results in Error 3012: No current record. In the specific case above, when at EOF, no error is raised, which violates my expectation based on the documentation.
Mind you, I'm not complaining, as the observed behavior is what I want to happen.
What bothers me is that I'd hate to write code that depends on undocumented behavior that could change at any time. Is there any evidence or documentation anywhere that the observed behavior is intended and not a corner case that slipped through the cracks?