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.
How To Make An Access Form Time Picker
Here is a relatively easy way to select times for your time entry text boxes. It’s a reusable form that allows you to pick a time from an Access form. There are probably different ways to do this but here is the way I would do it. On the form that has the time fields, […]
How to pick a file to load In VBA
Picking a file to load in your Microsoft App is a very important skill to know. In this blog post you will see how to do it. First you need to set a reference to the MS office object library From VBE editor –> select Tools > MS office object library (click check mark) Sub […]
What is the purpose of the Me keyword in Access VBA?
What does the Me keyword mean? “Me” refers to the Access form currently in focus. Instead of writing out the entire form reference, you can just use the keyword “Me” which is easier. Like: Me.txtbox = “I am a textbox on the form that currently has the focus.” or you can update a label’s caption […]
How can I interact with other Office applications (Excel) using VBA in Access?
Need to write your Access data or query to an Excel file? Here is the how to do it: Most people are familiar with Excel and know how to use it well (enough), and when you start talking about Access, they get scared off, and don’t know what to do anymore. Well, here you are […]