Parameter query to find null dates at runtime

  • Thread starter Thread starter bobdydd
  • Start date Start date
B

bobdydd

Hi Everybody

I am trying to be able to filter records by whether the date field
which is called "RiskDate" in the
recordset, is either:

1. Is Null
2. Not Null

The parameter in the query field RiskDate is:
Like "*" & [Forms]![frmCommissionContainer]![ComboRiskDate]

But I cannot figure what to put in ComboRiskDate to supply the
parameter at runtime.

Most grateful if anyone could help.
 
One approach would be to put anything you like in the combo box ("Null" and
"Not Null" or even "Red" and "Blue" if that means something to you).

You'd then want the WHERE clause in your SQL to look like:

WHERE ((RiskDate IS NULL) AND
([Forms]![frmCommissionContainer]![ComboRiskDate] = "Null"))
OR ((RiskDate IS NOT NULL) AND
([Forms]![frmCommissionContainer]![ComboRiskDate] = "Not Null"))

You might be able to specify this in the query grid as:

IS NULL AND [Forms]![frmCommissionContainer]![ComboRiskDate] = "Null"

on one line, and

IS NOT NULL AND [Forms]![frmCommissionContainer]![ComboRiskDate] = "Not
Null"

on another line, although I'd recommend going into the SQL view and making
sure it's correct.
 
Hi Everybody

I am trying to be able to filter records by whether the date field
which is called "RiskDate" in the
recordset, is either:

1. Is Null
2. Not Null

The parameter in the query field RiskDate is:
Like "*" & [Forms]![frmCommissionContainer]![ComboRiskDate]

But I cannot figure what to put in ComboRiskDate to supply the
parameter at runtime.

Most grateful if anyone could help.

Well, Like won't work. What are the actual values of the bound column in
ComboRiskDate? If (e.g.) it's the text strings IS NULL and IS NOT NULL, try

WHERE (RiskDate IS NULL AND [Forms]![frmCommissionContainer]![ComboRiskDate]
= "IS NULL")
OR (RiskDate IS NOT NULL AND [Forms]![frmCommissionContainer]![ComboRiskDate]
= "IS NOT NULL")


John W. Vinson [MVP]
 
Thanks guys

Some success

I managed to do this in the query grid by putting in the RiskDate
Column

0. Is Null
1. Is Not Null

I then added another "Unseen column" with "Forms]!
[frmCommissionContainer]![ComboRiskDate"
and then put
0
Or 1
In that column. And bingo the combo box selects correctly
 

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