DCount Not Working

Cavman

Registered User.
Local time
Today, 01:21
Joined
Oct 25, 2012
Messages
66
Help - my DCount's not working! Here it is:

Code:
 Me.txtOrdersToday = DCount("[AccountNo]", "tblAccountBase", "[UserID] = " & UserID & " AND [AccountOrderedFocusThisP] = TRUE AND [StatusDate] = #" & Date & "#")

This DCount returns '0', however, the following query returns '2', which is correct:

Code:
 SELECT Count(tblAccountbase.AccountNo) AS CountOfAccountNo, tblAccountbase.UserID, tblAccountbase.AccountOrderedFocusThisP, tblAccountbase.StatusDate
FROM tblAccountbase
GROUP BY tblAccountbase.UserID, tblAccountbase.AccountOrderedFocusThisP, tblAccountbase.StatusDate
HAVING (((tblAccountbase.UserID)=41) AND ((tblAccountbase.AccountOrderedFocusThisP)=True) AND ((tblAccountbase.StatusDate)=Date()));

Can anyone tell me why the query works but the DCount doesn't? I've set a breakpoint and the UserID is definitely '41' and the DCount works if I omit the Date criteria at the end so I'm guessing it could be something to do with the date criteria format, but I've tried changing them still with no luck.

Thanks,

Simon
 
Hmmm.. Might be because the format are a bit different.. If you use ## the system automatically converts it to mm/dd/yyyy.. Try this..
Code:
Me.txtOrdersToday = DCount("[AccountNo]", "tblAccountBase", "[UserID] = " & UserID & " AND [AccountOrderedFocusThisP] = TRUE AND [StatusDate] = " & CDbl(Date) & "")[B]
[/B]
 
Brilliant, that worked Paul! Thanks
 
You are welcome Cavman.. Glad to Help.. Good day.. :)
 

Users who are viewing this thread

Back
Top Bottom