How do I assign a control to a variable AS Control

  • Thread starter Thread starter Wes from Scottsdale
  • Start date Start date
W

Wes from Scottsdale

Dim cControl As Control

cControl = Me.cboSomething

I can pass cboSomething into a function as a control, but I need to retain
the control for later use.

Thanks.
 
Sorry, I don't understand exactly what you're trying to do. Can you give a
more detailed explanation?

"retain the control for later use" where? In the same procedure" There
shouldn't be any issue. What problem are you having?
 
I'm passing a control to a function. I want to save the control to a module
variable so that I can reference the passed control later outside of the
function.

Dim cLastControl As Control 'Module Level
Private Function A(cControl As Control)
cLastControl = cControl '**This fails**
'Rest of function code...
End Function
 
You need to use the Set keyword when dealing with controls:

Set cLastControl = cControl
 
Back
Top