Hi,
I have created a search form which returns only exact matches:
Private Sub cmdSearch_Click()
Dim strItemNameRef 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 an Item Name!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in strItemName
DoCmd.ShowAllRecords
DoCmd.GoToControl ("strItemName")
DoCmd.FindRecord Me!txtSearch
strItemName.SetFocus
strItemNameRef = strItemName.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in strItemName and shows msgbox
'and clears search control
If strItemNameRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Search Complete"
strItemName.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "No Media Found For: " & strSearch & " - Please Try Again.", _
, "Search Complete"
txtSearch.SetFocus
End If
End Sub
I need help to modify it so that it returns all matching variants. For example if I have items called 'Windows XP, Windows Server, Windows ME' & did a search for 'Windows' I want it to return all three items.
At them moment I have to type in the exact name to get a match. Please Help . . . . .
I have created a search form which returns only exact matches:
Private Sub cmdSearch_Click()
Dim strItemNameRef 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 an Item Name!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------
'Performs the search using value entered into txtSearch
'and evaluates this against values in strItemName
DoCmd.ShowAllRecords
DoCmd.GoToControl ("strItemName")
DoCmd.FindRecord Me!txtSearch
strItemName.SetFocus
strItemNameRef = strItemName.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in strItemName and shows msgbox
'and clears search control
If strItemNameRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Search Complete"
strItemName.SetFocus
txtSearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "No Media Found For: " & strSearch & " - Please Try Again.", _
, "Search Complete"
txtSearch.SetFocus
End If
End Sub
I need help to modify it so that it returns all matching variants. For example if I have items called 'Windows XP, Windows Server, Windows ME' & did a search for 'Windows' I want it to return all three items.
At them moment I have to type in the exact name to get a match. Please Help . . . . .