How To Open A Form To A Specific Record In Access 2016 VBA

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.

Here’s “frmCustomers”

Here’s “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 & "'"
End Sub

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:


Need to pass multiple parameters? Click here

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

Tags: ,