Iif statement where false has no condition

zkoneffko

Registered User.
Local time
Today, 05:08
Joined
Jun 4, 2008
Messages
13
I have drop down menus on a form that I use in an iif statement in a query to narrow the results according to what is selected. However they will have the option to leave the drop down blank and I want it to return all possbible results. How do I write an iif statement to return all items if that drop down is left blank?
 
use following Sql in the query
Code:
SELECT Table1.Text1
FROM Table1
WHERE 
(((Table1.Text1)=[FORMS]![FORM1]![COMBO1]) 
AND 
(([FORMS]![FORM1]![COMBO1]) Is Not Null)) 
OR 
((([FORMS]![FORM1]![COMBO1]) Is Null))

assuming
table name is table1
form name is form1
combo name is combo1 (which is being used as criterea)

now if you wont select any thing in combo1 then query will show all record
 
The example below is quoted from a post by Jon K

Basic Criteria Format
The example basically sets the criteria for each field in a separate column in the query grid like this in query Design view:-
-------------------------------------
Field: [FieldName]=[Forms]![FormName]![ControlName] or [Forms]![FormName]![ControlName] Is Null

Show: uncheck

Criteria: True
-------------------------------------
The [Forms]![FormName]![ControlName] Is Null enables us to leave the text box/combo box on the form blank. The True in the criteria row tells Access to treat the expression in the field row as the criteria.
 

Users who are viewing this thread

Back
Top Bottom