Writing Expressions in Access

C

Casey P

This is a simple expression, I just am having issues today. I am trying to
write an expression that show the difference between 2 fields and if the
second field is 0 then no total would display.
 
C

Casey P

OK so this is what I have
= iif(Reviewed Value) = 0, null, ([Complete Date] - [Reviewed Value)

I get a Syntax Error
 
C

Casey P

iif Reviewed value is "0" then Cut Value is "0" otherwise Original Cost -
REviewed Value in Cut Value

That is what I trying to write. I can do the subraction expression fine,
but I am having a block when it comes the the rest.
 
J

John Spencer

Watch those parentheses and square brackets. They must match up. I think
what you need is:

IIF([Reviewed Value] = 0, null, [Complete Date] - [Reviewed Value])


Casey P said:
OK so this is what I have
= iif(Reviewed Value) = 0, null, ([Complete Date] - [Reviewed Value)

I get a Syntax Error

iif(nz(Field2) = 0, null, abs(field1 - field2))



Chris Nebinger
 
C

Casey P

Huh, I knew it was something simple. I was leaving the "null" out!

Thanks sir.

John Spencer said:
Watch those parentheses and square brackets. They must match up. I think
what you need is:

IIF([Reviewed Value] = 0, null, [Complete Date] - [Reviewed Value])


Casey P said:
OK so this is what I have
= iif(Reviewed Value) = 0, null, ([Complete Date] - [Reviewed Value)

I get a Syntax Error

iif(nz(Field2) = 0, null, abs(field1 - field2))



Chris Nebinger

Casey P wrote:
This is a simple expression, I just am having issues today. I am
trying to
write an expression that show the difference between 2 fields and if
the
second field is 0 then no total would display.
 
J

John Vinson

OK so this is what I have
= iif(Reviewed Value) = 0, null, ([Complete Date] - [Reviewed Value)

I get a Syntax Error

Count parentheses and square brackets. You have no closing square
bracket after Reviewed Value, and you have two left parentheses and
only one right parenthesis. They've got to balance!

Try

= iif(Reviewed Value) = 0, null, ([Complete Date] - [Reviewed Value]))


John W. Vinson[MVP]
 
Top