L
Lirva S via AccessMonster.com
I have the following code on a "Search" command button. The code works fine
except that I'm not sure where the put the part that advises the user that
the data they entered in the txtSearch is not found. I've tried placing it
in many different parts of the code but can't seem to get it to work.
Can someone tell me where to it shoud go. Thanks!
------------------------------------------------------
Private Sub cmdSearch_Click()
'On Error GoTo Err_cmdSearch_Click
Dim strSQL As String
Dim strTextEntry As String
'*** create the string based on the information on the form
strSQL = ""
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch].SetFocus
Else
strTextEntry = txtSearch
MsgBox strTextEntry & " is not found.", , "Sorry!"
txtSearch.SetFocus
End If
' The fields to search
strSQL = strSQL & "[StudentID] Like '*" & Me![txtSearch] & "*' OR [Student]
Like '*" & Me![txtSearch] & "*' OR [Status] Like '*" & Me![txtSearch] & "*'"
'Data source
strSQL = "SELECT qryStudent.* FROM qryStudent WHERE " & strSQL
except that I'm not sure where the put the part that advises the user that
the data they entered in the txtSearch is not found. I've tried placing it
in many different parts of the code but can't seem to get it to work.
Can someone tell me where to it shoud go. Thanks!
------------------------------------------------------
Private Sub cmdSearch_Click()
'On Error GoTo Err_cmdSearch_Click
Dim strSQL As String
Dim strTextEntry As String
'*** create the string based on the information on the form
strSQL = ""
'Check txtSearch for Null value or Nill Entry first.
If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch].SetFocus
Else
strTextEntry = txtSearch
MsgBox strTextEntry & " is not found.", , "Sorry!"
txtSearch.SetFocus
End If
' The fields to search
strSQL = strSQL & "[StudentID] Like '*" & Me![txtSearch] & "*' OR [Student]
Like '*" & Me![txtSearch] & "*' OR [Status] Like '*" & Me![txtSearch] & "*'"
'Data source
strSQL = "SELECT qryStudent.* FROM qryStudent WHERE " & strSQL