Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a control

Status
Not open for further replies.

BasicBoy

Programmer
Feb 22, 2008
156
ZA
I wish to set a control of which I only have its name stored in a database in a string field 'cboList' like in:

Set MyControl="cboList"

It gives an error because the string "cboList" is not a control object.
Thanks for help
 

Code:
Dim c As Control

For Each c In Me.Controls
    If c.Name = "cboList" Then
        Set MyControl = c
        Exit For
    End If
Next

If you do that a lot in your code, I would set a little Function where you pass the name of the control as String, and return the control as Control.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Which you'll notice is pretty similar to the answer you got in thread222-1680716
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top