gojets1721
Registered User.
- Local time
- Today, 11:58
- Joined
- Jun 11, 2019
- Messages
- 430
I have the below command that allows the user to search a field in a form and filter to whatever the user inputs. It works great but I just realized that if no matching records are found, the form just goes completely blank. This requires the user to exit the form and get back in.
Ideally, if no records are found, it will stay on the current record and just populate a msg box stating nothing found. Any suggestions on how to code that?
Ideally, if no records are found, it will stay on the current record and just populate a msg box stating nothing found. Any suggestions on how to code that?
Code:
Private Sub btnSearchCategory_Click()
On Error GoTo btnSearchCategory_Click_Err
Dim S As String
S = InputBox("Enter Category", "Category Search")
If S = "" Then Exit Sub
Me.Filter = "Category LIKE ""*" & S & "*"""
Me.FilterOn = True
btnSearchCategory_Click_Exit:
Exit Sub
btnSearchCategory_Click_Err:
MsgBox "Error #" & Err.Number & " - " & Err.Description, , "Error"
Resume btnSearchCategory_Click_Exit
End Sub