Hello Everyone,
I want to get my Dcount formula count the number of records based on two criteria. For that I wrote the code below. However it gives me type mismatch error. Where do I do wrong? Thanks a lot.
_____________________________________
Private Sub Komut178_Click()
Dim variable As String
variable = DCount("[formname]", "[formusertable]", "[formname] = '" & Me.txtname.Value & "'" And "[userno] = " & Me.numuserno.Value & "")
MsgBox variable
End Sub
_____________________________________
Formname and userno are the fields of table "formusertable"
Formname is string while userno is integer.
And please note that, I have tried those two criteria seperately in the formula, and it runs perfectly like below. But when I combine like above, it is not working.
variable = DCount("[formname]", "[formusertable]", "[formname] = '" & Me.txtname.Value & "'")
variable = DCount("[formname]", "[formusertable]", "[userno] = " & Me.numuserno.Value & "")