Checking for Null Dates in search criteria

N

Neil

Hello,

I am trying to count how many fields in my table are greater than a certain
date. I have the code below:

-------------------------------------------------
rsTemp!lngJobsAtStartOfWeek = DCount("dteDateCompleted", "tblMain", _
"dteDateCompleted > #" &
Format(DateAdd("d", -1, _
Format(dteTemp, "Medium Date")), "Medium
Date") & "#")
--------------------------------------------------

This counts all completed dates in my main table that are greater than the
date passed in to the procedure (dteTemp). How do I also include fields in
dteDateCompleted that do not contain a date and have just been left blank? I
will be hitting myself when someone tells me the answer! :)

TIA,

Neil.
 
A

Allen Browne

Count something that is not null, and include Is Null as part of the
criteria:

=DCount("*", "tblMain", "(dteDateCompleted Is Null) OR (dteDateCompleted > "
& Format(dteTemp - 1, "\#mm\/dd\/yyyy\#") & ")")
 
N

Neil

Thanks Allen,

Couple of questions. What is happening now that "*" is used as the criteria.
I thought this had to be the field name for the table? Also, your format
function is hell of a lot better than what I had to do! Does the \/dd\/ mean
that days will be added (or subtracted in this case)?

Thanks again,

Neil.
 

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

Top