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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Next and Previous buttons for a sub form. 1

Status
Not open for further replies.

Plumes

Technical User
Jan 27, 2004
18
AU
Hi All

I have a main form with a subform within it and I want to add next and previous buttons on the footer of the main form to cycle thought the records in the sub form. Does anyone know the code or how?

I tried this but no success

Private Sub cmd_Previous_Record_Click()
On Error GoTo Err_cmd_Previous_Record_Click


DoCmd.GoToRecord acDataForm, Forms![SubForm], acPrevious

Exit_cmd_Previous_Record_Click:
Exit Sub

Err_cmd_Previous_Record_Click:
MsgBox Err.Description
Resume Exit_cmd_Previous_Record_Click

End Sub

Thanks

Matt
 
Assumning your subform control is named frmYourSubform, then add the following line of code before your Docmd.GoToRecord line in the navigation button on main form
[tt]
frmYourSubForm.SetFocus
[/tt]
This will move the focus to the subform, which will then become the object of the GoToRecord method.


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Steve,

Once again Steve you've produced the goods, that worked a treat.

Thanks

Matt
:)
 
Cheers Steve,

You've just solved the problem for me too!!



Aubs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top