I am building a Microsoft Access database form that has a couple of subforms, each in their own tab in a tab control. I also have a list box inside one of the subforms that displays all records that match the Primary Key of the record open in the main form. Let’s call those primary records A, B, C… and the subform records that match 1,2,3…
Maybe in the subform table that looks like this
Record MainRecordKey
1 A
2 A
3 A
4 B
5 B
6 B
I want to create a button in the main form that both switches to the next Primary Key record in the main form and updates that list box to show the correct information.
I have made a button that updates the list with the expression builder enter image description here. So when I move to record B, I press the button and it updates so that 4,5,6 shows instead of 1,2,3.
That works, but the issue is I cannot find a way to also switch records just using the expression builder. At the same time, I cannot get the list box to update using VBA (I assume I am referencing it wrong). Right now I have, inside the On_Click property VBA editor:
Private Sub GoNext_Click()
Me![individualsSubformTab].Form!SubformList.Requery
End Sub
From the sources I checked this should be sufficient but I have tried every type of reference I can. “individualSubFormTab” is the name of the Subform control in the main form. “SubformList” is the name of the list box.
No idea about the next steps but I really want to make it work with VBA so I can include the code to go to the next record. I would be happy to provide more info if needed.
Zachary Leffel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.