Hi all...
I have some search code that works great for searching just one field within the database, but I would like it to search multipal fields if possible..... I have tried to modify it without success... I would like it to search employeenumber, social security number and lastname
I am wondring if it is possible to modifiy it.
Here is the code:
Thanks
R~
P.S. Can't remember where I got this code from, but thanks it works like a charm!!!!
I have some search code that works great for searching just one field within the database, but I would like it to search multipal fields if possible..... I have tried to modify it without success... I would like it to search employeenumber, social security number and lastname
I am wondring if it is possible to modifiy it.
Here is the code:
Code:
Private Sub cmdSearch_Click()
Dim strEmployeeNumber 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 ("EmployeeNumber")
DoCmd.FindRecord Me!txtSearch
EmployeeNumber.SetFocus
strEmployeeNumber = EmployeeNumber.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in strStudentID and shows msgbox
'and clears search control
If strEmployeeNumber = strSearch Then
'MsgBox "Match Found For: " & strSearch, , "Congratulations!"
EmployeeNumber.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
Thanks
R~
P.S. Can't remember where I got this code from, but thanks it works like a charm!!!!