D
Dan
Ok...I have the following field in a query that returns a
DIVIDE by ZERO error:
Field4: Sum([Units]/(DLookUp
("[FieldA]","[Table1]","[FieldB] = '" & [Field1] & "'")))
It is the Dlookup that sometimes returns a zero and hence
the error.....so to try to avoid the error I am using an
iif statement..
Example
iif(DLookUp("[FieldA]","[Table1]","[FieldB] = '" &
[Field1] & "'") = 0, 0, Sum([Units]/(DLookUp
("[FieldA]","[Table1]","[FieldB] = '" & [Field1] & "'"))))
This should return 0 when my divisor is 0 else return the
function value....However I've noticed and later read
that "The IIf function always evaluates both the truepart
and the falsepart, even though it returns only one
value. Because of this, you should watch for undesirable
side effects. For example, if evaluating the falsepart
results in a division by zero error, an error occurs even
when the expression is True."
So is there a workaround to this? Please help!!! Any
suggestions are greatly appreciated!
Thanks,
Dan
DIVIDE by ZERO error:
Field4: Sum([Units]/(DLookUp
("[FieldA]","[Table1]","[FieldB] = '" & [Field1] & "'")))
It is the Dlookup that sometimes returns a zero and hence
the error.....so to try to avoid the error I am using an
iif statement..
Example
iif(DLookUp("[FieldA]","[Table1]","[FieldB] = '" &
[Field1] & "'") = 0, 0, Sum([Units]/(DLookUp
("[FieldA]","[Table1]","[FieldB] = '" & [Field1] & "'"))))
This should return 0 when my divisor is 0 else return the
function value....However I've noticed and later read
that "The IIf function always evaluates both the truepart
and the falsepart, even though it returns only one
value. Because of this, you should watch for undesirable
side effects. For example, if evaluating the falsepart
results in a division by zero error, an error occurs even
when the expression is True."
So is there a workaround to this? Please help!!! Any
suggestions are greatly appreciated!
Thanks,
Dan