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

Multi-Layer Conditional IIf Statement 1

Status
Not open for further replies.

bowieknife

Technical User
Oct 21, 2005
24
US
All -

I have a time card database that tracks...well, you get the picture. Within the QryTimeCard (fed by TblTimeCard), I have a conditional iif statement that reads:

SunTotal: IIf((([SunTimeOut]-[SunTimeIn])*24)>=8,((([SunTimeOut]-[SunTimeIn])*24)-0.5),(([SunTimeOut]-[SunTimeIn])*24))

and this accounts for a 1/2 hour lunch if the individual works 8 hours or more.

I also have a field for each day in TblTimeCard (Yes/No) that accounts for "No Lunch" (eg. [SunNoLunch], etc.). The intent of this field is that when a user checks this box, it will add .5 hours back to their daily total (eg. [SunTotal] (=([SunTimeOut]-[SunTimeIn])*24). If they uncheck it later, I want it to take the 1/2 hour out of their daily total.

Should this be performed witha form-level macro or a multi-level iif statement in the query?

Thank you in advance.

JB
 
embed it in the query (XXX = your calculation):

So, taking it apart:

If it's < 8 hours, XXX
If it's >= 8 hours and [SunNoLunch] = True, XXX
If it's >= 8 hours and [SunNoLunch] = False, XXX-.5

iif(Blah < 8 or (Blah >=8 and [SunNoLunch] = True), XXX, XXX-.5)

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Ginger -
Thank you. That worked extremely well and I understand the process. Thanks for your help.

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top