Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

turning a combo box into a search field

Status
Not open for further replies.

Nkuha

Programmer
Jan 8, 2002
7
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top