<fr********@aol.com> wrote in message
news:40**************************@posting.google.c om...
I have created a database in MS Access 2000. I want to compute for
percent defective and in the control source I have this expression:
=(([no_defective]/[no_made])*100). Its OK if I have the numbers
greater than zero. But when I get a zero value on both fields I get
the #num! error value. I need help on how I can return a value to
zero when I get the #num!error value. Please help, I'm very desperate.
In fact the problem is caused when no_made is zero. The field no_defective
could be a positive number and the error would still occur. The problem is
you can't divide by zero, so you need to catch this case with, for example:
IIf([no_made]>0,([no_defective]/[no_made])*100,Null)
Additionally, if your database allows for null values, you might like to
catch the case when say 25 have been made, and there is a null value in the
[no_defective] field:
IIf([no_made]>0,(Nz([no_defective],0)/[no_made])*100,Null)