Iif statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table that contains the field "Task Complete?". Data is entered into
the table via a form. The form has a check box for "Task Complete?" and
therefore enters "0" into the table if the check box is not selected (task
incomplete) or "-1" into the table if the check box is selected (task
complete).

I have a query in which is controlled by another form. In the form is a
combo box with "Complete", "Incomplete" and "All", allowing the user to
search complete, incomplete and all tasks (there are other fields that are
searched, such as task name and task details).

I am having trouble creating the query for this. So far, I have

IIf([Forms]![Task Query Input]![Task Complete?]="Complete",
"-1",(IIf(Forms![Task Query Input]![Task Complete?]="Incomplete","0",
<<falsepart>>))

It is the <<falsepart>> I am having toruble with. I have tried numerous
things, including "0" or "-1", Like "*", "*" but nothing seems to work. I
either get an error, or on selecting "All" in the combo box, I get all
incomplete (0) tasks.
 
Try this --
IIf([Forms]![Task Query Input]![Task Complete?]="Complete",
-1,IIf(Forms![Task Query Input]![Task Complete?]="Incomplete",0, Like"*"))
 
Try this as the criteria.

Assumption:
The field [Task Complete?] is a boolean field (yes/no) or if it isn't then it
always has a value.

Field: [Task Complete?]
Criteria: IIf([Forms]![Task Query Input]![Task Complete?]="Complete",-1,
IIf(Forms![Task Query Input]![Task Complete?]="Incomplete",0,[Task Complete?]))




KARL said:
Try this --
IIf([Forms]![Task Query Input]![Task Complete?]="Complete",
-1,IIf(Forms![Task Query Input]![Task Complete?]="Incomplete",0, Like"*"))

mhayli said:
I have a table that contains the field "Task Complete?". Data is entered into
the table via a form. The form has a check box for "Task Complete?" and
therefore enters "0" into the table if the check box is not selected (task
incomplete) or "-1" into the table if the check box is selected (task
complete).

I have a query in which is controlled by another form. In the form is a
combo box with "Complete", "Incomplete" and "All", allowing the user to
search complete, incomplete and all tasks (there are other fields that are
searched, such as task name and task details).

I am having trouble creating the query for this. So far, I have

IIf([Forms]![Task Query Input]![Task Complete?]="Complete",
"-1",(IIf(Forms![Task Query Input]![Task Complete?]="Incomplete","0",
<<falsepart>>))

It is the <<falsepart>> I am having toruble with. I have tried numerous
things, including "0" or "-1", Like "*", "*" but nothing seems to work. I
either get an error, or on selecting "All" in the combo box, I get all
incomplete (0) tasks.
 
Thanks John. Put -1 and 0 in " ", and it worked a treat.

John Spencer said:
Try this as the criteria.

Assumption:
The field [Task Complete?] is a boolean field (yes/no) or if it isn't then it
always has a value.

Field: [Task Complete?]
Criteria: IIf([Forms]![Task Query Input]![Task Complete?]="Complete",-1,
IIf(Forms![Task Query Input]![Task Complete?]="Incomplete",0,[Task Complete?]))




KARL said:
Try this --
IIf([Forms]![Task Query Input]![Task Complete?]="Complete",
-1,IIf(Forms![Task Query Input]![Task Complete?]="Incomplete",0, Like"*"))

mhayli said:
I have a table that contains the field "Task Complete?". Data is entered into
the table via a form. The form has a check box for "Task Complete?" and
therefore enters "0" into the table if the check box is not selected (task
incomplete) or "-1" into the table if the check box is selected (task
complete).

I have a query in which is controlled by another form. In the form is a
combo box with "Complete", "Incomplete" and "All", allowing the user to
search complete, incomplete and all tasks (there are other fields that are
searched, such as task name and task details).

I am having trouble creating the query for this. So far, I have

IIf([Forms]![Task Query Input]![Task Complete?]="Complete",
"-1",(IIf(Forms![Task Query Input]![Task Complete?]="Incomplete","0",
<<falsepart>>))

It is the <<falsepart>> I am having toruble with. I have tried numerous
things, including "0" or "-1", Like "*", "*" but nothing seems to work. I
either get an error, or on selecting "All" in the combo box, I get all
incomplete (0) tasks.
 
Back
Top