I have a PopUp Form containing two listboxes (the control I refer to is the child listbox). Parent listbox has no multi-select property; child listbox (in question) mutli-select (simple) & an optionGroup (irrelevant) with other irrelevant buttons...
I imagine an explicit ListBox obj var type would eradicate the issue but I cannot see why i cannot pass a generic control then ascertain what that control type is in an external procedure; allowing for simpler processing of the control type. Reference the childListbox control; unless an explicit reference is used:
Which is not suitable as I need to assign the controls at run-time. I can pass the string reference of the control name to another procedure & that's fine but it would be much better to pass the actual control itself; or better not have to pass the control & use the Screen.ActiveControl property in the called procedure.
Any ideas why this is happening?
- MouseDown event assigned to a txtBox in the child listbox
- Correctly reads Me.ActiveControl.Name as the child listbox.
- Screen.ActiveControl.Name = (Error 2474 - control to be in active window). Google suggests Screen.ActiveControl will always return the control which had the focus when the event was activated). This does not seem to be the case & I mention multiple listboxes incase this is the issue; though I think it should not be.
- Since 1.1 can access the control name correctly it should be able to assign an obj var of that control (child listbox) either with:
-
Code:
Set ctl = Me.ActiveControl
Set a string var based on name of ActiveControl & use that to reference the Controls collection. EDIT - this works but the others should also work & want to learn WHY?- Let alone should be able to reference Screen.ActiveControl.
-
I imagine an explicit ListBox obj var type would eradicate the issue but I cannot see why i cannot pass a generic control then ascertain what that control type is in an external procedure; allowing for simpler processing of the control type. Reference the childListbox control; unless an explicit reference is used:
Code:
Set ctl = Controls("childListBoxName")
Which is not suitable as I need to assign the controls at run-time. I can pass the string reference of the control name to another procedure & that's fine but it would be much better to pass the actual control itself; or better not have to pass the control & use the Screen.ActiveControl property in the called procedure.
Any ideas why this is happening?
Last edited: