I'm trying to return a reference to a checkbox, but the following code does not work as I expect.
Private Function ck() as Access.CheckBox
ck = Me.ckExample
End Function
The full function takes parameters and has flow control to choose which control to return, but this is a minimal example to demonstrate the problem. This function errors out with the message
Run-item error '91': Object variable or With block variable not set
As far as I can tell it's attempting to set ck
to the value of Me.ckExample
rather than as a reference to the control, despite it being properly declared. I'm at a loss as to how to do this correctly. I've also attempted declaring it as Control
, as well as assigning to a temporary variable declared with Dim ckTemp as Access.CheckBox
.