Gotorecord: jump to first record in subform when

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
 
A

Allen Browne

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
 

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