list box selecting record on form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list box that is connected to a table that has a primary key that is
made up of two fields (key1, key2). WHen you click on it the form goes to
that record. However, right now the vba code looks like:

' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[key1] = " & Chr(34) & Me![List101] & Chr(34)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Right now if there is multiple key1 values it just goes to the first record.
How can I add key2 in?
 
Assuming that the key1 value is the bound column, and that key2 is the 2nd
column in the combo box, try

rs.FindFirst "[key1] = " & Chr(34) & Me![List101] & Chr(34) & " And [key2] =
" & Chr(34) & Me![List101].Column(1) & Chr(34)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top