using iif but coming up with error#

  • Thread starter Thread starter Rivers
  • Start date Start date
R

Rivers

ok i have the if down but its causing me a brain drain lol

i want to divide my hours utilised by the amunt of pallets moved but all its
coming out with is an error# sign

PPH: IIf([Delivery Type]="Palletised",[hours]/[pallets])

PPH = pallets per Hour

any ideas
 
There are two things that stand out.
First, you have no False condition specified in your IIf. That is what
value to assign if [Delivery Type]<>"Palletised"

The other is that you cannot divide by zero or Null. You need to include
code to transform the values of 0 and Null for the divisor and you need to be
sure the number you are dividing is not Null:

PPH: IIf([Delivery Type]="Palletised",Nz([hours],0)/Nz([pallets],1),0)
 
ok itried your string which worked exactly like my version but still gave an
error i believe its because the hours is in time rather than integer

Klatuu said:
There are two things that stand out.
First, you have no False condition specified in your IIf. That is what
value to assign if [Delivery Type]<>"Palletised"

The other is that you cannot divide by zero or Null. You need to include
code to transform the values of 0 and Null for the divisor and you need to be
sure the number you are dividing is not Null:

PPH: IIf([Delivery Type]="Palletised",Nz([hours],0)/Nz([pallets],1),0)
--
Dave Hargis, Microsoft Access MVP


Rivers said:
ok i have the if down but its causing me a brain drain lol

i want to divide my hours utilised by the amunt of pallets moved but all its
coming out with is an error# sign

PPH: IIf([Delivery Type]="Palletised",[hours]/[pallets])

PPH = pallets per Hour

any ideas
 
That may be the problem. Time is a decimal value. It may be you need to
convert Hours to an integer
--
Dave Hargis, Microsoft Access MVP


Rivers said:
ok itried your string which worked exactly like my version but still gave an
error i believe its because the hours is in time rather than integer

Klatuu said:
There are two things that stand out.
First, you have no False condition specified in your IIf. That is what
value to assign if [Delivery Type]<>"Palletised"

The other is that you cannot divide by zero or Null. You need to include
code to transform the values of 0 and Null for the divisor and you need to be
sure the number you are dividing is not Null:

PPH: IIf([Delivery Type]="Palletised",Nz([hours],0)/Nz([pallets],1),0)
--
Dave Hargis, Microsoft Access MVP


Rivers said:
ok i have the if down but its causing me a brain drain lol

i want to divide my hours utilised by the amunt of pallets moved but all its
coming out with is an error# sign

PPH: IIf([Delivery Type]="Palletised",[hours]/[pallets])

PPH = pallets per Hour

any ideas
 
Back
Top