Forum Discussion
Should be easy...... Open a form to a specific record
I have a form with rows showing individual audit for staff members. Each audit would be individualized by an Autonumber ID field.
I want the user to be able to click on the ID field, have it close the form, and open another form on that specific record. Both forms are based on the same underlying table.
The VBA I'm trying is the following:
Private Sub ID_Click()
DoCmd.OpenForm "Case_Notes", acNormal, "[ID] = " & Me!ID
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
It does open the other form, close the form the user is clicking from, but it does not go to the ID number I click. For example, I click on ID 3, and the other form opens on ID 2.
Any help would be greatly appreciated! Let me know if you have questions that I haven't clarified.
1 Reply
- HeinziATIron Contributor
WhereCondition is the fourth parameter of `DoCmd.OpenForm`, not the third.
See https://learn.microsoft.com/en-us/office/vba/api/access.docmd.openform for a documentation of `DoCmd.OpenForm`. The examples there match quite closely what you are trying to do.