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 aMyComboOrListBox
control update dynamically when the value of theCompanyID_Control
changes:You'll also need to set the
AfterUpdate
property of theCompanyID_Control
to:[Event Procedure]
.Note that even if you use linked tables as Remou suggested, you will still need code in the
AfterUpdate
event of theCompanyID_Control
to refresh your combobox/listbox RowSource: