Query

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

Hi all I have a problem with my query. Where i have the query divide the a
from b and it is to display an average. But the problem I am having is when
i test the query it is saying devide by zero. How do I get the query to
overlook this.

Thanks

Greg
 
Instead of using

[Field1]/[Field2]

try

[Field1]/IIf(Nz([Field2],0) = 0, 1, [Field2])

That will give you the value of [Field1] when there's no value for [Field2].
If you'd like some other value in that case, you can use:

IIf(Nz([Field2], 0) = 0, <your value>, [Field1]/[Field2])
 
Thanks for that

Greg
Douglas J. Steele said:
Instead of using

[Field1]/[Field2]

try

[Field1]/IIf(Nz([Field2],0) = 0, 1, [Field2])

That will give you the value of [Field1] when there's no value for
[Field2]. If you'd like some other value in that case, you can use:

IIf(Nz([Field2], 0) = 0, <your value>, [Field1]/[Field2])

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Greg said:
Hi all I have a problem with my query. Where i have the query divide the
a from b and it is to display an average. But the problem I am having is
when i test the query it is saying devide by zero. How do I get the
query to overlook this.

Thanks

Greg
 
Back
Top