Query Should Continue if Value is Null

  • Thread starter Thread starter Shawn Oatley
  • Start date Start date
S

Shawn Oatley

Hello,

I want to run a query that has to WHERE fields but if one of the field should be null, then still run the query.

For example:
SELECT from Links where Category=[Forms]!frmLinks![cboCategory] AND SubCategory = [Forms]!frmLinks![SubCategory]

But, should the category in question have no Sub Categories, I would like the query to run, but not require the SubCategory field.

I have tried assigning the form to using an SQL recordsource that I can change as I check the SubCategory (if it is null or not) but when I change the Recordsource property it comes back with a 2001 error (You cancelled the previous option).

Any ideas???

Shawn
 
Try

SELECT from Links where Category=[Forms]!frmLinks!
[cboCategory] AND (SubCategory = [Forms]!frmLinks!
[SubCategory] OR [Forms]!frmLinks![SubCategory]
is null)

hth

Chris
-----Original Message-----
Hello,

I want to run a query that has to WHERE fields but if one
of the field should be null, then still run the query.
For example:
SELECT from Links where Category=[Forms]!frmLinks!
[cboCategory] AND SubCategory = [Forms]!frmLinks!
[SubCategory]
But, should the category in question have no Sub
Categories, I would like the query to run, but not require
the SubCategory field.
I have tried assigning the form to using an SQL
recordsource that I can change as I check the SubCategory
(if it is null or not) but when I change the Recordsource
property it comes back with a 2001 error (You cancelled
the previous option).
 
Bingo!!!

That was too easy!!
Thanks!
Shawn

Try

SELECT from Links where Category=[Forms]!frmLinks!
[cboCategory] AND (SubCategory = [Forms]!frmLinks!
[SubCategory] OR [Forms]!frmLinks![SubCategory]
is null)

hth

Chris
-----Original Message-----
Hello,

I want to run a query that has to WHERE fields but if one
of the field should be null, then still run the query.
For example:
SELECT from Links where Category=[Forms]!frmLinks!
[cboCategory] AND SubCategory = [Forms]!frmLinks!
[SubCategory]
But, should the category in question have no Sub
Categories, I would like the query to run, but not require
the SubCategory field.
I have tried assigning the form to using an SQL
recordsource that I can change as I check the SubCategory
(if it is null or not) but when I change the Recordsource
property it comes back with a 2001 error (You cancelled
the previous option).
 
Back
Top