I have this code in a txtSearchBox field on a form, when the text the user types is not on list in the form I get an error and have to close the form to refresh it.
I would like to figure out how to give the user a message saying " the text you typed is not in the list" and then have the code refresh the screen and let them continue.
Any help would be appreciated.
Also see attached pic of the form, each of the columns has similar code for it's textbox.
I would like to figure out how to give the user a message saying " the text you typed is not in the list" and then have the code refresh the screen and let them continue.
Any help would be appreciated.
Also see attached pic of the form, each of the columns has similar code for it's textbox.
Code:
Private Sub txtJobNameFilter_Change()
Dim sText As String
Dim strFilter As String
On Error GoTo ErrHandler
sText = Me!txtJobNameFilter.Text
If sText <> "" Then
strFilter = "[JobName] Like '*" & sText & "*'"
Me.Filter = strFilter
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
With Me.txtJobNameFilter
.SetFocus
.Value = sText
.SelStart = Len(sText)
.SelLength = 0
End With
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub