VBA, yes. JET Sql, no.
Try these tests:
Sub temp()
Debug.Print IIf(1, 5, 5 / 0) 'error
End Sub
Sub temp2()
Debug.Print DBEngine(0)(0).OpenRecordset("SELECT IIf(1, 5, 5 / 0) FROM
MSysObjects")(0) 'r
End Sub
<rant>
That being said I am 100% opposed to IIf([BilledHours]=0,0,[Fees]/
[BilledHours])
If there are no hours then there is no rate.
My answer to:
How can I have it return a zero when it's dividing by zero?
is
take a time warp to another universe ... no, not even that. God cannot
make x / 0 = 0. Probably we should not try what defies God.
It is better both from a logical point of view and from modelling real
life to do:
Rate: [Fees]/[BilledHours]
WHERE BilledHours <> 0
and leave rate as null where BilledHours = 0.
Inevitably IIf([BilledHours]=0,0,[Fees]/[BilledHours]) will lead to
error because it is a contrivance, a dangerous bad contrivance.
Somwehere, sometime it will grab you and destroy you. Why. Because
it's WRONG!
Is this arrogant and pedantic? Sure. The reverse is why North American
manufacturing and business is failing. Rigor? We don't need no
stinking rigor! Just make some money today and get that bonus.
Eventually this will bring failure, has brought failure.
</rant>
On Apr 23, 5:45*pm, "paii, Ron" <n... (AT) no (DOT) com> wrote:
Quote:
You may get an error with that expression, VBA executes the entire
expression even if [BilledHours] = 0. |