Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statement

Status
Not open for further replies.

douggy

Technical User
Jan 18, 2001
78
GB
I have a field which displays the result of a calculation.

The field is based on the following:

Stock Turn VOL Weeks: [Stock Volume]/[Sales Volume]*52

I want to adpat this so that it performs this calculation if the field [Sales Volume] is greater than zero. Otherwise I wish to insert the word 'INF'.

Can anyone help.

Thanks
Mark
 
Try:
Code:
Stock Turn VOL Weeks: IIf([Sales Volume]>0,[Stock Volume]/[Sales Volume]*52,"INF")
Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
I try to never use IIf() where the true and false expressions are different data types. My recommendation would be to return Null and then use the Format property of a text box to display "INF" if the value is Null.
Code:
Stock Turn VOL Weeks: IIf([Sales Volume]>0,[Stock Volume]/[Sales Volume]*52,Null)

Duane
Hook'D on Access
MS Access MVP
 
Thanks both of you. Great help. Dhookom, can you just explain in a little more detail how I format the property of a text box.

Thanks
Mark
 
There is decent documentation on this in Help. Search on "Format Number". The format property allows you to enter 4 different format expressions for numeric values displayed in text boxes. These are separated by a semi-colon. The expressions are for:
-positive values
-negative values
-zero
-Null

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top