问题描述
Private Sub cmdsearch_Click()
On Error Resume Next
Dim strNDetails As String
Dim strSearch As String
'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
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in strStudentID
DoCmd.ShowAllRecords
DoCmd.GoToControl ("NDetails")
DoCmd.FindRecord Me!txtSearch
NDetails.SetFocus
NDetails = NProvider.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in strStudentID and shows msgBox
'and clears search control
If NDetails Like "*" = strSearch Then
MsgBox "Match Found For: " & strSearch,"Congratulations!"
NDetails.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgBox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.",_,"Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub
解决方法
尝试:
If NDetails Like "*" & strSearch & "*" Then