search form code

D

Deb H

I am using an unbound search form to show a record from a subform. My
search form contains an unbound combo box (List2) of all the subform records.
The search form only works if I select a subform record from the combo box
that is related to the first record on the main form (Registrations). If I
select some other
record, I don't get an error message. It simply takes me to the first record
in the main form. How can I get it to move to the correct record on the main
form and highlight the selected record in the subform?
I am a novice in using VBA so any help is much appreciated.

This is the code for the command button (ShowRecord2) on my search form:

Private Sub ShowRecord2_Click()
'Find the selected record and then close the search form
Dim rst As DAO.Recordset

Set rst = Forms![Registrations]![Childsubform].Form.RecordsetClone

'Locate the record for the selected child
rst.FindFirst "ChildID = " & List2

'Set the form's bookmark property to move to the record
Forms!Registrations!Childsubform.Form.Bookmark = rst.Bookmark

DoCmd.Close acForm, "FindChild"

End Sub
 

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

Top