How to query when control param is null?

  • Thread starter Thread starter David Portwood
  • Start date Start date
D

David Portwood

I want to run a query with criteria based on a form control. Works fine for
nonblank values in the control but when the control is null the query finds
no records, even though records do exist with null values in that field.

Does anybody know how I can fix this?
 
You cannot use a parameter to find Null. By its nature, Null is not equal to
Null (i.e.: Null = Null will never return True)

If the parameter is Null, do you want only Null values returned, or do you
want all the rows returned?

If the former, your SQL should be something like

WHERE MyField = Forms!MyForm!MyControl OR (MyField IS NULL AND
Forms!MyForm!MyControl IS NULL)

If the latter, your SQL should be something like

WHERE MyField = Forms!MyForm!MyControl OR Forms!MyForm!MyControl IS NULL
 

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

Back
Top