Reputation: 447
I have a form in Access with a textbox and a combobox, and need to filter the combobox dropdown options using the value in the textbox. The textbox contains a Category
for the choices.
I've done this using
SELECT Options.Choice
FROM Options
WHERE (((Options.Category)=[forms]![FormName]![Text10].Value));
Is there a way to refer to the value in Text10
without explicitly referring to FormName
?
I'll need to duplicate this form within the same Access file and changing all combobox row sources for a new form is not feasible. I can't hard code the Category value for each combobox because there are many comboboxes per form, and the value in the textbox will be different on every form. Any help is appreciated.
Upvotes: 0
Views: 1065
Reputation: 1034
You can refer to whatever form you're currently on in Access using Screen.ActiveForm. So in your case you'd have:
SELECT Options.Choice
FROM Options
WHERE (((Options.Category)=[Screen].[ActiveForm]![Text10].Value));
As long as the field name stays constant this should work.
Upvotes: 2