I am confused on how the IsError function works (or doesn't work for that matter).
I have a SELECT statement that includes an expression:
Notice that if B.bar is a "zero" value, division by zero occurs. So I implemented the IIF and IsError functions thinking that the IsError will return a True / False value if/when an error occurs. Then the IIF would return "safe" values based on the IsError's returned value.
Here's an example of the function implementation.
When I run the query with the functions, I get a return of "#Error" if the divisor (B.bar) equals zero. Based on how I wrote the query, I would think that I should see a return of "bad" instead of "#Error". For all results that did not have a zero value in the divisor, I am getting a result of "good" back - which is what I expect.
Can anyone fill me in on why my SELECT statment does not return "bad" when an error occurs in the expression?
Please let me know if I you need further explanation - I would really enjoy hashing this one out with anyone interested.
I have a SELECT statement that includes an expression:
Code:
SELECT (A.foo/B.bar) AS Expr1
FROM A INNER JOIN B...
Notice that if B.bar is a "zero" value, division by zero occurs. So I implemented the IIF and IsError functions thinking that the IsError will return a True / False value if/when an error occurs. Then the IIF would return "safe" values based on the IsError's returned value.
Here's an example of the function implementation.
Code:
SELECT IIF(IsError((A.foo/B.bar)),"bad","good") AS Expr1
FROM A INNER JOIN B...
When I run the query with the functions, I get a return of "#Error" if the divisor (B.bar) equals zero. Based on how I wrote the query, I would think that I should see a return of "bad" instead of "#Error". For all results that did not have a zero value in the divisor, I am getting a result of "good" back - which is what I expect.
Can anyone fill me in on why my SELECT statment does not return "bad" when an error occurs in the expression?
Please let me know if I you need further explanation - I would really enjoy hashing this one out with anyone interested.