K
KateB
Hi everyone,
I have a search box on a form that works great provided the number entered
exists in the database. However, if it is incorrect (i.e. not found) it
gives me a blank page. I can go back to my form by clicking the filter
button in the menu but the people who will be using the form won't know to do
that (and won't remember even if I tell them!) If I post the code can anyone
suggest what I can add so that it gives a message telling them its invalid
and to try again? (and where to add it! I am self-taught and everything I
use has been found and adapted from this forum or some of the excellent web
sites suggested).
Many thanks in advance, Kate
Private Sub NHSNoSearch_Click()
On Error GoTo Err_NHSNoSearch_Click
Dim FilterStr As String
If IsNumeric(txtNHSnumber) = True Then
FilterStr = "QryAllPtInfo.NHSnumber = " & txtNHSnumber
Me.Filter = FilterStr
End If
Debug.Print FilterStr
Me.FilterOn = True
Exit_NHSNoSearch:
Exit Sub
Err_NHSNoSearch_Click:
MsgBox Err.Description
Resume Exit_NHSNoSearch
End Sub
I have a search box on a form that works great provided the number entered
exists in the database. However, if it is incorrect (i.e. not found) it
gives me a blank page. I can go back to my form by clicking the filter
button in the menu but the people who will be using the form won't know to do
that (and won't remember even if I tell them!) If I post the code can anyone
suggest what I can add so that it gives a message telling them its invalid
and to try again? (and where to add it! I am self-taught and everything I
use has been found and adapted from this forum or some of the excellent web
sites suggested).
Many thanks in advance, Kate
Private Sub NHSNoSearch_Click()
On Error GoTo Err_NHSNoSearch_Click
Dim FilterStr As String
If IsNumeric(txtNHSnumber) = True Then
FilterStr = "QryAllPtInfo.NHSnumber = " & txtNHSnumber
Me.Filter = FilterStr
End If
Debug.Print FilterStr
Me.FilterOn = True
Exit_NHSNoSearch:
Exit Sub
Err_NHSNoSearch_Click:
MsgBox Err.Description
Resume Exit_NHSNoSearch
End Sub