I have this code:
Code:
'In sub form module
sub button_click()
me.parent.updateList
'In parent form module
Public Sub updateList()
Dim vID As Integer
Dim vIDS() As String
vID = Me![Grand Unifying Table subform].Form.ID
'It'd be nice to find a way to ensure that vID is a number, but it doens't really matter
'List274 is a list box on the parent form. This assignment normally works, but here, g and h evaluate to null
g = Me!List274
h = Me.List274
'Using set is normally not necessary, but in this case it is
Set i = Me!List274
clearListBox (i)
'In normal module
' as control normally not necessary, as isn't by ref, necessary here...
sub clearListBox(byref ctl as control)
that get's called from a click event on a subform. Normally, when an event on the parent form refers to a control on a mainform,
g=Me!control works fine
Here, I need
set i = Me!List274 because the scope is block scope I supposed, but it's really slow. Like setting i to Me!List274 makes the computer think about it for five seconds.
Me.Parent.List274 doesn't work because this line executes in the scope of the parent form
When I hover my cursor over i or Me!List274, its null, but in the immediate window it's Variant/Object/ListBox and when I do ?i.name, it's List274
Finally, if I add Dim i as listbox, it's nothing in the immediate windows, but changes to ListBox after the set i..., but hovering the cursor over the variable still shows null
Also passing to down to a procedure in a normal module doesn't work, I get object required even though i is clearly an object.
I've tried clearListBox (Me!List274) also, but that has failed.
I removed the "as Control" and it works, but then ctl is null and there is no object
I've also tried "as Object" to cast it as a base class, but that's failed too.
Then I tried moving the sub to the parent form module, and it still doesnt' work not matter what.
Finally, in the parent form module, I added the line set ctl = Me!List274, and it's null with the cursor, but ctl.ListCount etc. works so I can manipulate the ctl as is normal. I'm obviously doing something wrong, but there is nothing on the web to explain this behavior. If the initial control firing the event was on the parent form, none of this would have been an issue