Query Issue

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Query Issue

Post by Carol W. »

Attached is a zip file containing a stripped down, compacted version of a donor database I wrote four years ago. It is currently running under Access 2010 but the behavior I'm about to describe is idential under Access 2003 (I tried it on an old machine of mine).

The query in question is qry-Socks-Thank You Letter. When I input dates 12/13/10 as the start date and 12/13/10 as the end date, I would expect to see two records. I see no records. However, when I remove the criteria under [Donor Last Name] (<> "Anonymous") I then see the two records that I expect to see.

I don't understand why removing that criteria makes the query work as expected since there are no records in the [Donor Table] whose Last Name field = "Anonymous". Therefore, nothing should be excluded, but it is.

Also, I have not included donation records for individuals with a last name but these did get returned by the query without removing the criterial under [Donor Last Name].

Here is my question: Why does removing that criteria make the query work as expected? The same situation holds true for the other query, qry-Socks-Thank You Letter-sort by zip.

Thank you, in adance.
You do not have the required permissions to view the files attached to this post.
Carol W.

User avatar
HansV
Administrator
Posts: 78594
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Query Issue

Post by HansV »

Two records have a null (empty) Donor Last Name. Null is not a value, it indicates the absence of a value, so Null is neither equal to "anonymous" nor not equal to "anonymous". Change the condition to

<>"Anonymous" Or Is Null

to catch both names unequal to "anonymous" and null values.
Best wishes,
Hans

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Query Issue

Post by Carol W. »

Thank you, Hans.

Your solution works, not only in the stripped down database in which there were only donations for donors whose [Donor Last Name] field was null but also in the production database where the query (after changing it to your criteria) selected both (1) donations for donors whose [Donor Last Name] was null and (2) donations for donors whose [Donor Last Name] was not null and not "Anonymous".

Thanks again.
Carol W.