Dcount Criteria

G

Guest

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\#"))
 
G

Guest

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

Similar Threads

Access Dcount (multiple criteria) 3
Access Dcount function in access 0
Dcount operation 2
Syntax for DCount Code 4
DCount multiple criteria (date range and text field) 2
DCount alwaysreturning 1 0
Access MS Access DCount function problem 0
Odd DCount problem 6

Top