I have the following code that works perfect on another form where the criteria fields are text data type. On this form, the StudentName is a text field and ClassID is a number field. I keep getting Run-Time Error '3075' Missing operator in Query Expression. Can someone tell me why I get this error on this form.
Private Sub cmdSearch_Click()
Dim strFilter As String
Dim intRecordCount As Integer
If (Len(txtSearchStudentName) & "") > 0 Then strFilter = "[StudentName]='" & txtSearchStudentName & "'"
If (Len(txtSearchClass) & "") > 0 Then
If Len(strFilter) > 0 Then strFilter = strFilter & " And "
strFilter = strFilter & "[ClassID]=" & txtSearchClass & ""
End If
If DCount("*", "tblRegistration", strFilter) = 0 Then
MsgBox "No record found.", vbInformation + vbOKOnly, "No Record Found!"
Else
intRecordCount = DCount("*", "tblRegistration", strFilter)
MsgBox intRecordCount & " record(s) found.", vbInformation + vbOKOnly, "Records Found!"
Me.Filter = strFilter
Me.FilterOn = True
End If
End Sub