Avatar of meena76
meena76
 asked on

Moving through a subform using gotorecord method

I am working with Microsoft Access 2000.  The porblem I am expericing is with a subform.  I am trying to use the gotorecord method to move to the next record in the subform.  When I run the code I get a message stating that the object is not open.  The event is triggerd by a button on the sub form.  How do I use the gotorecord method on a subform.
Microsoft Access

Avatar of undefined
Last Comment
harfang

8/22/2022 - Mon
harfang

GoToRecord works either on a named object or on the current object (default parameter acActiveDataObject). Since a subform has no name, this is your only choice. Make sure the subform is active (i.e. the main form is active and the subform has the focus  this isn't a problem as the button *is* on the subform) and use:

    DoCmd.GoToRecord Record:=acGoTo, Offset:=108

To go to the last, first, etc, you also have RunCommand acCmdRecordsGoTo???

Finally, you can also use the recordset object of the subform:

    Me.subFormControlName.Form.Recordset.AbsolutePosition = 107

(because .AbsolutePosition is 0-based), or more to the point, as this is run *from* the subform:

    Me.Recordset.AbsolutePosition = 107

Cheers!
(°v°)
meena76

ASKER
Need clarification how do you make the subform active.
ASKER CERTIFIED SOLUTION
harfang

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Your help has saved me hundreds of hours of internet surfing.
fblack61