DCount

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

Guest

I want use the DCount function but I am having problems with criteria
expression. When I run the code, it keeps telling me there is "data mismatch
in the criteria expression". [Days to Complete] is a field where the data
type is Number. int1 is an integer but I have also made it string.
[ESDStaffName] is a field where the data type is Text. strStaffName is
string. Do I have to change the field [Days to Complete] to a different
data type? Any help is appreciated. Thank you.

intSameDay = DCount("[ID]", "PM Date Errors Asc", "[Days to Complete] ='" &
int1 & "' And [ESDStaffName] = " & "'" & strStaffName & "'")
 
Try:
intSameDay = DCount("[ID]", "PM Date Errors Asc", "[Days to Complete] =" &
int1 & " And [ESDStaffName] = """ & strStaffName & """")
 
Try this:

intSameDay = DCount("[ID]", "PM Date Errors Asc", "[Days to Complete] =" &
int1 & " And [ESDStaffName] = '" & strStaffName & "'")

Make sure int1 is a number or use CLng(int1) instead.
I want use the DCount function but I am having problems with criteria
expression. When I run the code, it keeps telling me there is "data mismatch
in the criteria expression". [Days to Complete] is a field where the data
type is Number. int1 is an integer but I have also made it string.
[ESDStaffName] is a field where the data type is Text. strStaffName is
string. Do I have to change the field [Days to Complete] to a different
data type? Any help is appreciated. Thank you.

intSameDay = DCount("[ID]", "PM Date Errors Asc", "[Days to Complete] ='" &
int1 & "' And [ESDStaffName] = " & "'" & strStaffName & "'")
 
Back
Top