How do I assign a pass-through query to Row Source that is dependent on another value in the form?
Essentially I want to do this:
SELECT x.companyid,
x.companyname,
x.productid
FROM x
WHERE (((x.CompanyID) = [Forms]![Reporting]![CompanyID_Control]))
ORDER BY x.productid;
But of course pass-through queries do not support reference to any form controls.
I have read here that there is a method via VBA, however I do not know how to use VBA in conjunction with the Row Source of a control.
As Remou stated in his answer, linked tables will make this easier. However, if you have a pass-through query named
MyQuery, you can do the following to make the RowSource of aMyComboOrListBoxcontrol update dynamically when the value of theCompanyID_Controlchanges:You'll also need to set the
AfterUpdateproperty of theCompanyID_Controlto:[Event Procedure].Note that even if you use linked tables as Remou suggested, you will still need code in the
AfterUpdateevent of theCompanyID_Controlto refresh your combobox/listbox RowSource: