MS Access Subform Navigation Buttons

In the following example the ms access subform gets its value from parent form.

In our example we have a main form which shows the customers and the subform which shows all the orders for the customer:

Independently the forms function by themselves, however it is more meaningful if they are combined.

This is how to connect the 2 forms (frmCustomers and frmOrders):

Now I’m going to show you how to add some vertical navigation buttons to your subform:

We have 2 vertical navigation buttons here (oleUp and oleDown), and here is the code:

Private Sub oleDown_Click()

    On Error Resume Next
    DoCmd.GoToRecord , , acPrevious

End Sub

Private Sub oleUp_Click()

    On Error Resume Next
    DoCmd.GoToRecord , , acNext
    
End Sub

We are using the “On Error Resume Next” because we have an error when we get to the beginning of the recordset and at the end. So this is the easiest way, in my opinion, of handling this.

Let me know if you have any questions.



Offsite Related Information:

“Go Fund Me” Page


($5 suggested amount)

(…10% of your gift amount will go to charity)

Free! Subscribe To Our YouTube Channel!

Free MS Access VBA Programming Course

Facebooktwitterredditpinterestlinkedinmailby feather
Tags: ,