Add controls to Frames at Runtime
Neily,
Here is some example code
Private Sub CreateControl()
Dim newButton As msforms.Control
Select Case True
Case chkText.Value
Set newButton = Me.Controls.Add("Forms.Textbox.1")
newButton.Name = "New Textbox"
Case chkButton.Value
Set newButton = Me.Controls.Add("Forms.CommandButton.1")
newButton.Caption = "newCmd"
Case chkCheckbox.Value
Set newButton = Me.Controls.Add("Forms.Checkbox.1")
newButton.Caption = "Another Checkbox"
End Select
With newButton
.Left = 100
.Top = 50
.Visible = True
End With
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Neily" wrote in message
...
Hi,
I am using the following code to add a frame to a form..
Set AddMyControl = Controls.Add("Forms.Frame.1", "fraFrame1", Visible)
AddMyControl.Left = 50
AddMyControl.Top = 50
AddMyControl.Caption = "New Frame Box"
AddMyControl.Width = 70
AddMyControl.Height = 50
I then want to add, say a checkbox into that frame. Anybody done this
before, got any ideas how it codes?
Thanks.
|