Aug 14, 2016 #1 BasicBoy Programmer Joined Feb 22, 2008 Messages 156 Location 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
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
Aug 15, 2016 #2 Andrzejek Programmer Joined Jan 10, 2006 Messages 8,576 Location US 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. Upvote 0 Downvote
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.
Aug 18, 2016 #3 strongm MIS Joined May 24, 2001 Messages 20,260 Location GB Which you'll notice is pretty similar to the answer you got in thread222-1680716 Upvote 0 Downvote