I am trying to set up a search bar that takes the value from my textbox and jumps from one matching record, to the next record, and so on. The data that I am using repeats numbers, not a lot of them but enough to make it relevant. So far I have been able to build a code that when I enter my number in a textbox and then click a command button, it jumps to the first instance that this number is found in my data and displays it on the form. I have not been able to get it to then jump to the NEXT instance of this number. I am not a great coder and I have been playing around with it, but my code that is currently able to find the first record is listed below, any help would be greatly appreciated!!
[code]
Private Sub cmdSearch_Click()
Dim strLocationRef As String
Dim strSearch As String
'Check txtcmdSearch 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 cmdSearch
'and evaluates this against values in Loc
DoCmd.ShowAllRecords
DoCmd.GoToControl ("Loc")
DoCmd.FindRecord Me!txtSearch
Loc.SetFocus
strLocationRef = Loc.Text
txtSearch.SetFocus
strSearch = txtSearch.Text
'If matching record found sets focus in Loc
If strLocationRef = strSearch Then
Loc.SetFocus
'If value not found sets focus back to cmdSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " -Please Try Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub
[code]
Thanks Again!