Null is generating #Error

homage

Registered User.
Local time
Today, 13:32
Joined
Dec 30, 2013
Messages
16
I have two tables that are joined together. I am trying to multiple hours and rate and I have the following expression:

Salary: IIF(Hrs=0,Null,((CCur(Rate*Hrs))

It works great except when Hrs are not null and Rate is null. I am getting #Error when I would like to get Null.
 
Something like:
IIF(Hrs=0 or Rate is null,Null,((CCur(Rate*Hrs))
Or is it
IIF(Hrs=0 or Isnull(Rate),Null,((CCur(Rate*Hrs))
 
See if this helps !
Code:
Salary: IIF(CCur(Nz(Rate, 0) * Nz(Hrs, 0)) = 0, Null, CCur(Nz(Rate, 0) * Nz(Hrs, 0)))
 
Code:
Salary: IIF(Nz([Hrs],0)=0 Or IsNull(Rate), Null, CCur(Rate*Hrs))
 
Thanks to everyone who answered. I used this one but really because it was in the first answer and it's what made the most sense to me.

IIF(Hrs=0 or Isnull(Rate),Null,((CCur(Rate*Hrs))

I'm not actually a programmer (not sure how obvious that is or will become).
 
If Hrs is Null it will still fail because CCur() cannot handle Null that was why I wrote a revised code.
 

Users who are viewing this thread

Back
Top Bottom