IF THEN Statement

  • Thread starter Thread starter TD
  • Start date Start date
T

TD

Is it possible to use an IF THEN Statement within a
query? Example: if then hours = 0, then display 0, else
display pieces/hours.

Thanks
TD
 
Yes, but in Access you use the iif() function to do
this. The format is iif(condition, truepart,
falsepart). These can also be nested. In your case it
would look something like:

iif([Hours]=0,0,[Pieces]/[Hours])

You may want to use the Nz() function though if it is
possible that Hours could be null, which is different
than 0, such as:

iif(Nz([Hours],0)=0,0,[Pieces]/[Hours])

HTH

-Ted Allen
 
Back
Top