Null values in query

M

mar10

I have a form with a dropdown box that allows the user to select a
YEAR. I then have a sub form based on a query referencing the selected
dropdown that shows the items that match the selected year.

There are records without YEARs and if the user does not select any
year I would like the subform to show ALL records.

I thought the "*" would work but it only picks up records with any
year, not null values.

I'm thinking I have obviously missed something simple here, but I'm
drawing a blank.

Any suggestions?

Thanks
 
M

MacDermott

One way is to use a WHERE clause in your query like this:
WHERE ([YEAR] = cboYEAR) OR (cboYear & "" = "")
 
S

Steve Schapel

Mar10,

In the criteria of the YEAR field in your query, put like this...
[Forms]![YourForm]![YourCombobox] Or [Forms]![YourForm]![YourCombobox]
Is Null

By the way, as an aside, I am not sure whether you are implying that you
have a field called Year, but 'year' is a Reserved Word (i.e. has a
special meaning) in Access, and as such it is probably best to avoid
using it as the name of a field or control.
 
Top