Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Dcount with date criteria 1

Status
Not open for further replies.

waterj4

MIS
Sep 14, 2005
3
US
I'm trying to check a table to see if it has any records that have been added today. In the table I have a [date created] field which is being createded with a default of now() and the format is set to short date.

I'm trying to use DCOUNT to count the records that have a today date. I will then apply an 'if..then' to it, but my DCOUNT isn't giving me the correct answer.

example #1

Code:
Dim varchecktoday As Variant
varchecktoday = DCount("[Field2]", "Cash master file", "[date created] = #" & Format(Now(), MM, DD, YYYY) & "#")
MsgBox varchecktoday, vbOKOnly

this gives me 0.

What am I missing?
 
varchecktoday = DCount("Field2", "[Cash master file]", "Int([date created]) = Int(Now())")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top