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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a function using If, then, else in a query 1

Status
Not open for further replies.

maryblu

Technical User
Aug 7, 2001
7
0
0
US
I would like to add a column in my query that asks the question if a certain field in my query is < or = to 5 then the number 184 should be entered if not then 224 should be entered. How do I build the the expression? The field I am refering to is Years of service (in a specific company) that uses the expression:12/365*(Now()-[Company Start Date])/12 to come up with the number of years of service. Now I want to calculate the number of hours of Pto that is accrued per years of service. If another expression is more appropriate to use please let me know.
 
iif(yearsofservice <=5,&quot;184&quot;,&quot;224&quot;)

You'll probably have to play with the syntax a little but this should do it. Thw way an IIf works is basically the same as an IF statement, the only difference is the IIF stands for Immediate IF statement and it evaluates as
iif( test,if true this is the result, if false this is the result)

I hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top