Reference Nested Form Fields in VBA
Reference Microsoft Access Form Controls from VB Script
Have you come across the maddening task of trying to reference a deeply nested
form, form field or control?
Here is a real example of a deeply nested subform control - a combo box control which we want to disable.
We have dozens of downloadable Access small business databases for you to learn and examine.
With our new partnership with IT Impact we have extensive programming support in SQL/Server database, MS Access software, Power BI applications, .Net web development, PHP, Excel & Outlook customization.
.Form![Parameter_Combo].Enabled = False
Isn't there an easier way to reference these fields directly? The
answer is YES!
You can reference any form directly using its reference in visual basic:
Form_F_Test_Result_Parameters.Parameter_Combo.Enabled = False
Notice that we prefix the form name with Form_ use the dot '.'
operator to reference the form control.
There is one trick to this referencing method - the form which you are
referencing must have its Has Module property set to Yes.
This method only seems to work in VBA code. Doesn't work when
referencing a form field as a query parameter nor in any of the property
Note that you can also reference a form's functions and subroutines using
the same method. For example:
(requeries the form)
(Note that the function or subroutine must be Public and not Private to
reference it from another form or VBA module.)
And requery a combo box after its row source updates: