Dcount Criteria

P

Paco

Any idea why these two dcounts return different values?

Dcount("*", "tblWR", "Created >= #4/29/2006#") (This returns the correct
count)
Dcount("*", "tblWR", "Created >= " & dtmRequestLimitDate) (This returns a
count of all records)

dtmRequestLimitDate is a public date variable that is set to Date(). It
shows the correct value when the code is run. I have a feeling there is
something about the syntax using a variable that I'm not seeing.

Thanks.
 
D

Douglas J. Steele

Just as you surrounded your date with # delimiters (and had it in mm/dd/yyyy
format), so too must you do that with the value you're passing from your
variable:

Dcount("*", "tblWR", "Created >= " & Format(dtmRequestLimitDate,
"\#mm\/dd\/yyyy\#"))
 
P

Paco

Perfect. Thanks.

Douglas J. Steele said:
Just as you surrounded your date with # delimiters (and had it in mm/dd/yyyy
format), so too must you do that with the value you're passing from your
variable:

Dcount("*", "tblWR", "Created >= " & Format(dtmRequestLimitDate,
"\#mm\/dd\/yyyy\#"))
 

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