In this post I am going to give you a basic example of how to open your Access form to a specific record.
This works in all versions of Access, but we are using Access 2016 in this example.
First create “parent and child” forms. In our case, it’s frmCustomers and frmOrders.
I have it in datasheet format just for viewing purposes. The same principles will apply for “single form”.
When I click the button “View Orders For This Customer”, I get what I asked for.
Here’s the code:
Private Sub btnOrders_Click()
DoCmd.OpenForm "frmOrders", acFormDS, , "CustomerID='" & Me.CustomerID & "'"
Basically this says “Open the Orders form in datasheet view, where CustomerID is equal to the customer I am currently viewing”
The quotes are around Me.CustomerID because in this table it is a text value!
Exclude the quotes if you are searching for a number value.
Let me know if you need any specific help.
Watch how it’s done: