[thechat] Anybody Remember IIF?
rudy
r937 at interlog.com
Fri Sep 7 22:49:15 CDT 2001
hey you lot
sorry for the delay adding to this thread but i'm not
a regular subscriber to this list
IIf is alive and well and living as a microsoft access function
i think it's also a visual basic function because the access help
file on IIf is a visual basic reference page
here's the basic syntax --
IIf(expr, truepart, falsepart)
expr = expression you want to evaluate.
truepart = value or expression returned if expr is True.
falsepart = value or expression returned if expr is False.
okay, now comes microsoft at its very best --
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 have always felt that if/else and case constructs were
invaluable in sql
here's an example of the microsoft access IIf function
used recursivelly --
SELECT Iif(Isnull(Mark),'?',
Iif(Mark>=80,'A',
Iif(Mark>=70,'B',
Iif(Mark>=60,'C',
Iif(Mark>=50,'D','F')))))
AS Grade
rudy
More information about the thechat
mailing list