Problems with dates in DCounts

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code is supposed to count how many calls an agent has logged on
this particular day, but it is returning the total number of calls made ever.
Can anyone see a problem with the date part?

lblCalls.Caption = DCount("*", "tbl_Main", "[AgentName]=""" &
[Forms]![frm_CallLogger]![txtAgentName] & """ And """ & "[SaveDate]=
DateValue(now)""")

Also I also want to build the date filter on this DCount but I can't get it
to work:

lblUpsells.Caption = DCount("*", "tbl_Main", "[AgentName]=""" &
[Forms]![frm_CallLogger]![txtAgentName] & """ And " & "[OutcomeFlush]=" &
"true" And """ & "[SaveDate]= DateValue(now)""")

Thanks for any help you can offer!
 
Try:

lblCalls.Caption = DCount("*", "tbl_Main", "[AgentName]=""" &
[Forms]![frm_CallLogger]![txtAgentName] & """ And """ & "[SaveDate]=" &
Format(Date, "\#mm\/dd\/yyyy\#"))

Same for the other one: put the date outside the quotes, use # delimiters
and format it as mm/dd/yyyy, regardless of what your Short Date format has
been set to. (the Format statement I'm using above does both the delimiter
and format for you)
 
Back
Top