Dcount with date criteria error

mcktigger

Registered User.
Local time
Today, 20:24
Joined
Apr 15, 2011
Messages
41
Hi all

Thought I had this sorted last week but a new issue has arisen. I have the following code on the BeforeUpdate event on a continuous form

Dim intcount As Integer

intcount = DCount("*", "[tblopportunities]", "[NextChase] =#" & [Forms]![FrmViewOpportunities]![NextChase] & "# and [CreatedBy] ='" & CurrentUser() & "'")
MsgBox intcount

I get this to work when the day is between 13 and 31 but when the day is between 01 and 12 the intcount is always zero.

I've tried a whole range of dates in 2012 and 2013 and it always seems not to work when the day is less than 13. Any help would be appreciated.

Thanks
 
Howzit

Try

Code:
intcount = DCount("*", "[tblopportunities]", "[NextChase] =#" & format([Forms]![FrmViewOpportunities]![NextChase],"mm/dd/yyyy") & "# and [CreatedBy] ='" & CurrentUser() & "'")
 
Perfect worked a treat. Thanks for your help :)
 

Users who are viewing this thread

Back
Top Bottom