DCOUNT with Date field

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

DCOUNT with Date field

Post by sal21 »

i ned to trap a date field in this piece of code, how to?

Code: Select all

  If DCount("*", strTable, "date1=" & Chr(34) & rst!date1& Chr(34)) > 1 Then


note:
date1 have a date short property
the code is an old code :grin:

User avatar
HansV
Administrator
Posts: 78417
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DCOUNT with Date field

Post by HansV »

Date values must be formatted using US format mm/dd/yyyy or international format yyyy-mm-dd, and enclosed in #, not in Chr(34):

Code: Select all

  If DCount("*", strTable, "date1=#" & Format(rst!date1,"yyyy-mm-dd") & "#") > 1 Then
Best wishes,
Hans