Let’s say I’ve got two tables, tblA and tblB, that have a 1:n relationship, i.e. for a given record in tblA there can be many records in tblB.
Now I have a form, frmA, that is based on tblA. On this form there is a command button that opens a second form, frmB, that is based on tblB. Now I want that second form frmB to only display records from tblB that match the current record from tblA.
I found that there is a built-in way (I use Access 2010) that filters the data from tblB. But since within frmB I need to do some more stuff based on the current record, this is not enough.
How do I do this then?
I thought of creating a query, qryAB, that does an inner join and has a parameter to select a certain record from tblA. But how would I pass something to this query to use as a parameter from the on-click macro (or vba) for my command button?
You can use the Where argument of the OpenForm method, you can add OpenArgs to OpenForm and you can refer to an already open form in code. It all depends on what you want to do next.