vba - Loop through every control in a form, with the form name defined as a variable -
i trying create basic search looks partial keyword match of control in specified form. form name selected via combo box , stored variable.
how use loop through controls of selected form?
i can loop through controls of current form following:
for each ctrl in me.controls debug.print ctrl.name next ctrl
but can't figure out how reference external form, variable replacing me
.
i've tried using:
dim ctrl control dim variablename string variablename = me.cmboformname each ctrl in forms(variablename).controls debug.print ctrl.name next ctrl
but returns error 438 (object doesn't support property or method).
you need dim ctrl well, , may have spaces in form name:
dim ctrl control dim variablename string variablename = "[" & me.cmboformname & "]" each ctrl in forms(variablename).controls debug.print ctrl.name next
Comments
Post a Comment