IIf Statement In Query

G

Guest

I have a data entry form with 4 check boxes on it labeled, Overnight,
Weekend, Part Weekend, & Holiday. In the underlying query I have a field
called total minutes, which calculates the total minutes a processor spent on
a task.

If the data entry clerk checks the Overnight check box on the form, I want
the query to subtract 360 minutes from the total minutes field. If Weekend
is checked, 3240 minutes, Partial Weekend, 1800 minutes, holiday, 1800
minutes.

The form allows more than 1 check box to be selected (which is what I want),
but the query is only subtracting the minutes from 1st box that is checked
and ignoring additional check boxes selected.

How do I force the query to evaluate each of the check boxes and subtract
the corresponding number of minutes from the total minutes field?

Here is my IIf statement:

FnlMins:
IIf([tblMoEmb_P]![Overnight]=True,([tblMoEmb_P]![TotalNumMins]-360),IIf([tblMoEmb_P]![PartWeekend]=True,([tblMoEmb_P]![TotalNumMins]-1800),IIf([tblMoEmb_P]![Weekend]=True,([tblMoEmb_P]![TotalNumMins]-3240),IIf([tblMoEmb_P]![Holiday]=True,([tblMoEmb_P]![TotalNumMins]-118),[tblMoEmb_P]![TotalNumMins]))))
 
J

Jeff Boyce

One approach to working on this might be to treat the calculation for each
checkbox separately, and add them all together.
 
G

Guest

from Hong Kong Rainbow01

Here my suggestion :
1) create a textbox(make it invisible) and a command button in your form
2) change your query parameter to : FnlMins---> =YourFormName!TextBox.Value
3) after tick the check box and click the command button(write your VBA
code), u can press your wanted value to the textbox,
run your query


"vmf" 來函:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top