NZ In Query

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have an Expression in a Query that isn't working. Can anyone see why?



Expr2: Nz([DiscountAmount],CCur([Expr1]-[DiscountAmount]),[Expr1])

If DiscountAmount is Null then its Expr1
Otherwise it's Expr1-DiscountAmount

Thanks
DS
 
DS said:
I have an Expression in a Query that isn't working. Can anyone see why?



Expr2: Nz([DiscountAmount],CCur([Expr1]-[DiscountAmount]),[Expr1])

If DiscountAmount is Null then its Expr1
Otherwise it's Expr1-DiscountAmount

Thanks
DS

Of Course, the minute I post it I figure it out!!!!

Expr2: CCur(Nz([Expr1]-[DiscountAmount],[Expr1]))

Sorry!
DS
 
You use the NZ as IIf, with two values, when NZ has only one value when null
Use that instead
IIF(isnull([DiscountAmount]),[Expr1],CCur([Expr1]-[DiscountAmount]))
 
Expr2: CCur(Nz([Expr1]-[DiscountAmount],[Expr1]))

or, more to the point:

Ccur([Expr1] - nz([DiscountAmount],0))
Limiting the Null test to DiscountAmount since you are apparently not
worried if Expr1 is Null.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


DS said:
DS said:
I have an Expression in a Query that isn't working. Can anyone see why?



Expr2: Nz([DiscountAmount],CCur([Expr1]-[DiscountAmount]),[Expr1])

If DiscountAmount is Null then its Expr1
Otherwise it's Expr1-DiscountAmount

Thanks
DS

Of Course, the minute I post it I figure it out!!!!

Expr2: CCur(Nz([Expr1]-[DiscountAmount],[Expr1]))

Sorry!
DS
 
Ofer said:
You use the NZ as IIf, with two values, when NZ has only one value when null
Use that instead
IIF(isnull([DiscountAmount]),[Expr1],CCur([Expr1]-[DiscountAmount]))
:

I have an Expression in a Query that isn't working. Can anyone see why?



Expr2: Nz([DiscountAmount],CCur([Expr1]-[DiscountAmount]),[Expr1])

If DiscountAmount is Null then its Expr1
Otherwise it's Expr1-DiscountAmount

Thanks
DS
Thank You
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top