View Full Version : Use combobox from form in query


bodylojohn
03-11-2008, 03:39 AM
Hello,

I have a form containing a combobox with the values yes (1) and no (2).

In my query I have a date field. When the value of the combo is yes only the dates should be displayed. is the value no the the empty fields should be shown. I nothing is selected all fields should be displayed.

I tried this:


IIf(IsNull([Forms]![Form1]![cboDate]);
IIf([Forms]![Form1]![cboDate]=1;[tblITEM]![date_ID] is not null; is null);[tblITEM]![date_ID])

But without success.

Jon K
03-11-2008, 11:34 AM
In my query I have a date field. When the value of the combo is yes only the dates should be displayed. is the value no the the empty fields should be shown. I nothing is selected all fields should be displayed.


Try this criteria in a NEW column in the query grid in query Design View:-

-------------------------------------------
Field: IIf([Forms]![Form1]![cboDate]=1; [tblITEM]![date_ID] is not null; IIf([Forms]![Form1]![cboDate]=2; [tblITEM]![date_ID] is null; True))

Show: uncheck

Criteria: True
-------------------------------------------

Note:
It's assumed that your version of Access uses ; rather than , as function argument separator and that [tblITEM]![date_ID] is the date field that you mentioned.
.