I have a search function in my database, see below:-
When the search finds the serial number it displays a message box with "Ok"
Because I have multiple entries with the same serial the search always only finds the first record.
Is there a way to adapt the above code so it displays a message box with 2 option buttons, one that says "Ok" and one that says "Next" whereby I can then use the Find Next function to search for the remaining serial numbers?
Ezzz
Code:
Private Sub cmdSearch_Click()
Dim SerialNumberRef As String
Dim Search 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 SerialNumber
DoCmd.GoToControl ("SerialNumber")
DoCmd.FindRecord Me!txtsearch
SerialNumber.SetFocus
SerialNumberRef = SerialNumber.Text
txtsearch.SetFocus
Search = txtsearch.Text
'If matching record found sets focus in SerialNumber and shows msgbox
'and clears search control
If SerialNumberRef = Search Then
MsgBox "Match Found For: " & Search, , "Congratulations!"
SerialNumber.SetFocus
txtsearch = ""
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & Search & " - Please Try Again.", _
, "Invalid Search Criterion!"
txtsearch.SetFocus
End If
End Sub
Because I have multiple entries with the same serial the search always only finds the first record.
Is there a way to adapt the above code so it displays a message box with 2 option buttons, one that says "Ok" and one that says "Next" whereby I can then use the Find Next function to search for the remaining serial numbers?
Ezzz
Comment