Negative calculated result to be changed to zero

Alrae1

New member
Local time
Tomorrow, 06:26
Joined
Aug 7, 2005
Messages
2
G'Day all, I am new to the forum family so please excuse any ignorance I may have in asking questions the right way.

The following at times depending on certain values creates a negative value.

WDCCFrm: [qry Areas]![Formation Value]-([qry Areas]![Formation Value]*((100/[qry Areas]![Formation_DesignLife])/100))*(DateDiff("yyyy",[BLOCK_DATA]![YEAR],Date()))

Due to the data requirements a negative value is not acceptable, it needs to be zero. The above is part of an Asset Managemnt Program and if the WDCC (Written Down Current Cost) is 0 then the item is written off. How do I change the negative value to a zero.
Any comments or suggestions would be appreciated.

Regards
Alrae1
 
Iif(MyExpression<0,0,MyExpression)

...will return zero if your expression is less than zero, otherwise it will return the expression value.
 
Hi mresann
Thanks for that. I had tried that but had an = in it and was causing me problems. Tried your solution and works perfectly.
Still learning Access. Once again thanks
Alrae1
 
The "=" value refers to how you want the expression to be used.

For form and report controls (mainly textboxes), you use the operator to set the value of the expression to the controls.

For queries and SQL statements, you don't need the operator of the expression.
 

Users who are viewing this thread

Back
Top Bottom