Asset Search

Ezz

New member
Local time
Today, 12:44
Joined
Jan 14, 2010
Messages
5
I have a cmd search function that searches my form for a specified Serial Number. See below:-
The problem is I have more than one asset with the same serial number, and the search only keeps finding the first record.
When the search finds the first asset is there a way to have another box to "Find Next" like in MS word so it continues to search the form for the next asset with that serial number?

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

Regards
Ezz
 
Ezz,

Foregive me if I get this wrong, but in form design view when using the command button wizard the first thing you see is find next, isn't this what you want?

It creates the code and you could edit it so that it will always focus on the field you want it to check for ! :)

There is also the find function dialog box you could use.
 

Users who are viewing this thread

Back
Top Bottom