Hello all. I am new to this forum. I need help with the following.
On my form, I have two unbound text fields, a search button and a rest button.
The code on the search button is
Private Sub cmdSearch_Click()
Dim strFilter As String
If (Len(txtSearchID) & "") > 0 Then strFilter = "[InstructorID]='" &_ txtSearchID & "'"
If (Len(txtSearchName) & "") > 0 Then
If Len(strFilter) > 0 Then strFilter = strFilter & " And "
strFilter = strFilter & "[InstructorName] Like '*" & txtSearchName & "*'"
Me.Filter = strFilter
Me.FilterOn = True
Else
MsgBox "No records found.", vbInformation + vbOKOnly, "No Record Found!"
End If
End Sub
My reset button just sets the me.filteron=false
This works fine except that when I first open the form and hit the search
button with nothing in the unbound fields, it applies the filter and shows a
blank record. Only after I reset once, then it starts popping up the message
saying no records was found.
Does anyone know why this happens?
Also, how can I modify this code to make it work with three and four criteria fields?
Thanks in advance