I tried doing this, and it works when I search for a primary key value, but it doesn't work when searching for a match in the "lastname" field. This first sub below works (the primary key one), but the second one doesn't. Below is the search function that performs the actual search.
The error msg I get is: "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". The line the code stops at is: "rs.Find searched & " = " & searcher". ("cmbjump" is the name of the combo-box)
Private Sub cmbjump_AfterUpdate()
searcher = (Nz(Me![cmbjump], 0)) ' what your searching for.
searched = "[cid]" 'where you're searching - this is the PK.
jumpsearch ' this function performs the search
End Sub
Private Sub cmbjump2_AfterUpdate()
searcher = (Nz(Me![cmbjump2], 0))
searched = "[lastname]" ' This time it's not the primary key
jumpsearch
End Sub
Function jumpsearch()
' Find the record that matches the control.
Dim rs As Object
Set rs = Form_record.Recordset.Clone
rs.Find searched & " = " & searcher 'error line
If Not rs.EOF Then Form_record.Bookmark = rs.Bookmark
DoCmd.Beep
End Function
The error msg I get is: "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". The line the code stops at is: "rs.Find searched & " = " & searcher". ("cmbjump" is the name of the combo-box)
Private Sub cmbjump_AfterUpdate()
searcher = (Nz(Me![cmbjump], 0)) ' what your searching for.
searched = "[cid]" 'where you're searching - this is the PK.
jumpsearch ' this function performs the search
End Sub
Private Sub cmbjump2_AfterUpdate()
searcher = (Nz(Me![cmbjump2], 0))
searched = "[lastname]" ' This time it's not the primary key
jumpsearch
End Sub
Function jumpsearch()
' Find the record that matches the control.
Dim rs As Object
Set rs = Form_record.Recordset.Clone
rs.Find searched & " = " & searcher 'error line
If Not rs.EOF Then Form_record.Bookmark = rs.Bookmark
DoCmd.Beep
End Function