Dcount Criteria

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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\#"))
 
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\#"))
 
Back
Top