Help with Dcount using multiple criteria

mcktigger

Registered User.
Local time
Today, 06:33
Joined
Apr 15, 2011
Messages
41
Hi

I'm trying to check if a timesheet for a certain employee on a certain date has been entered already and if so display a message. I'm using the Dcount function on the after update event on a combo box but keep getting o records. My code is

Dim IntCount As Long

IntCount = DCount("TimesheetID", "tbltimesheet", "[DriverID]=" & Me.DriverID.Value & " AND [Date]=" & Me.Date.Value)

I can get it to work on the first criteria only but when I add in the Date part it doesn't. I'm sure it's just my syntax but I've tried various options and can't seem to find a solution.

Would really appreciate any help.

Thanks
 
Dates in SQL should be surrounded by #s.

Code:
IntCount = DCount("TimesheetID", "tbltimesheet", "[DriverID] = " & Me.DriverID.Value & " AND [Date] = #" & Me.Date.Value & "#")
 
Hi cbrighton

It worked perfectly. I've been tearing my hair out for nearly 2 days on this so very much appreciated.

Thanks
 

Users who are viewing this thread

Back
Top Bottom