I have a combobox on a subform (ProgramSubform) in Access that's supposed to list report years for a project from a table (Program). Most projects have more than one report year, but the combobox always brings only 2014.
For example, the dropdown for project 5278 should be:
Instead, it's only
This is the select query that I'm using. It was working properly before, but I don't know when it stopped working; no changes were made to the tables or subform.
Any idea why it might have stopped working, or how to fix it?
Best How To :
WHERE clause asks Access to limit the rows returned by the query to those whose ProjNo values match the text string 'ProgramSubform.ProjNo'
But ProgramSubform.ProjNo is actually a data control on a subform. So don't include quotes around its name.
You can use a reference to the control via the parent form in the
WHERE Program.ProjNo= Forms![Parent Form]!ProgramSubform!ProjNo
If you're building the
SELECT statement with VBA code in the form, you can include the control's value instead of its name:
"WHERE Program.ProjNo=" & Me!ProgramSubform!ProjNo.Value
"WHERE Program.ProjNo='" & Me!ProgramSubform!ProjNo.Value & "'"
Use the first version for a numeric field or the second for text.
I assumed ProgramSubform is the name of the subform control. It could also be the name of the form contained in that subform control. But those names can be different. So make sure you used the subform control name.
This query is used as the Row Source for a combo box on the subform. You want to update the values displayed in the combo whenever
ProjNo.Value changes. You can accomplish that by calling the combo's
Requery method from the After Update event of