Gotorecord: jump to first record in subform when

  • Thread starter Thread starter jokobe
  • Start date Start date
J

jokobe

hi,

within a form I have a subform. When pushing a button in
the masterform, I want to jump to the first record in the
subform. I tried this:
Set my_form = Forms!master_form!sub_form.Form

DoCmd.GoToRecord acDataForm, my_form.name, acFirst

As an answer, I always get: (sub)form not open.

Any helpful hint?


jokobe
 
Because the subform is not open in its own right (i.e. it is not part of the
Forms collection), you cannot refer to it by name like that.

Try using the subform's RecordsetClone to move record:

Dim my_form As Form
Set my_form = Me.sub_form.Form
With my_form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
my_form.Bookmark = .Bookmark
End If
End With
Set my_form = Nothing
 
Back
Top