Move focus to record in subfrm datasheet based on cmbox selection

  • Thread starter Thread starter Elvira S.
  • Start date Start date
E

Elvira S.

I have a combobox on a main form where the user selects a
name that I then want to use to have the record selector
move to the matching record in a subform that is set to
datasheet view (its recordset is updateable). The bound
field of the cmbox is ResidentID. ResidentID is then saved
in the variable intResidentID. Is there a way to use the
DoCmd.FindRecord (or some other method) to get the focus to
move to record in the subform that matches intResidentID?
The subform has the RecordsetClone property available to it
but not from the main form. Can I invoke it somehow from
the mainform so I can bookmark the record? FYI: both the
main form and the subform have the same query as their
RecordSource. Also, using a filter isn't an option because
I need to have all the records on the subform be visible,
not just one at a time. Can anyone help me out with this?
 
Elvira said:
I have a combobox on a main form where the user selects a
name that I then want to use to have the record selector
move to the matching record in a subform that is set to
datasheet view (its recordset is updateable). The bound
field of the cmbox is ResidentID. ResidentID is then saved
in the variable intResidentID. Is there a way to use the
DoCmd.FindRecord (or some other method) to get the focus to
move to record in the subform that matches intResidentID?
The subform has the RecordsetClone property available to it
but not from the main form. Can I invoke it somehow from
the mainform so I can bookmark the record? FYI: both the
main form and the subform have the same query as their
RecordSource.


The combo box is unbound isn't it?

You can do this kind of thing to any open form or subform,
you just need to reference the desired form object. From a
main form to its subform, it will be along these lines:

With Me.subformcontrol.Form
.RecordsetClone.FindFirst "ResidentID = " & intResidentID
If Not .RecordsetClone.Nomatch Then
.Bookmark = .RecordsetClone.Bookmark
End If
End With
 
Thanks Marsh! My code was pretty close to that but a
little bit mixed up. Your suggestion works like a charm!
Muchas gracias!
 
Back
Top