Link to home
Create AccountLog in
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.
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

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°)
Avatar of meena76
meena76

ASKER

Need clarification how do you make the subform active.
ASKER CERTIFIED SOLUTION
Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account