GeorgeDurkee
Programmer
I am trying to dynamically add a check box to my form and can't seem to get the controls.add function to work right.
I've found a number of references to the corect code, like this: Set Control = object.Add( ProgID [, Name [, Visible]])
Here is my code:
Dim Mycmd As Control
Private Sub CommandButton1_Click()
Set Mycmd = Controls.Add("MSForms.CommandButton.1"
Mycmd.Left = 18
Mycmd.Top = 150
Mycmd.Width = 175
Mycmd.Height = 20
Mycmd.Caption = "This is fun." & Mycmd.Name
End Sub
When I run the code, I get an error 'Method or data member not found' on the .Add clause.
This tells me that I am missing a reference, but I don't know how to determine what I'm missing. I have the Microsoft Forms 2.0 Object Library loaded, but that doesn't seem to be the one want.
Any ideas?
Thanks
I've found a number of references to the corect code, like this: Set Control = object.Add( ProgID [, Name [, Visible]])
Here is my code:
Dim Mycmd As Control
Private Sub CommandButton1_Click()
Set Mycmd = Controls.Add("MSForms.CommandButton.1"
Mycmd.Left = 18
Mycmd.Top = 150
Mycmd.Width = 175
Mycmd.Height = 20
Mycmd.Caption = "This is fun." & Mycmd.Name
End Sub
When I run the code, I get an error 'Method or data member not found' on the .Add clause.
This tells me that I am missing a reference, but I don't know how to determine what I'm missing. I have the Microsoft Forms 2.0 Object Library loaded, but that doesn't seem to be the one want.
Any ideas?
Thanks