Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to move through records in a subform?

Status
Not open for further replies.

dave547

Programmer
Oct 26, 2001
5
US
I need to know how to move the record pointer on a subform by using a command button on the main form.
Any suggestions would be appreciated.
 
Had the same challenge .... try this

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

Set rst = Me.prod_subfrm.Form.RecordsetClone
rst.Bookmark = Me.prod_subfrm.Form.Bookmark
rst.MoveNext
Me.prod_subfrm.Form.Bookmark = rst.Bookmark
Exit Sub
rst.Close
rst = Nothing
Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
Resume Exit_Command6_Click

End Sub

In this case the main form was named FORM1 and the subform control on the main form was named prod_subfrm. The actual subform was named prod_subfrm9. I always try to name the control something other than the underlying subform's name. This ensures that the code can easily and uniquely identify what I really want rather on trying to decide on whether I meant the control or the subform contained in the control. This technique also works well for other field controls where there is a problem on what may be meant. I usually go to the control name and add a letter in front of the name (ie)the text box for the field Last_Name will be renamed to zLast_Name .

Hope this helps

Doug_R
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top