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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

control inside 1

Status
Not open for further replies.

plusminus

Technical User
Feb 19, 2005
4
0
0
NO
Please, answer me
How to put controls inside a frame control at run time
 
Hi,
Try this...
Code:
    Dim Mycmd As Control
    Set Mycmd = UserForm1.Frame1.Controls.Add("Forms.OptionButton.1")
    With Mycmd
        .Width = 15
        .Height = 10
        .Top = UserForm1.Frame1.Height - .Height - 5
        .Left = UserForm1.Frame1.Width - .Width - 5
    End With
Puts an option box in lower r-h corner of frame
VOLA! :)
Skip,
metzgsk@voughtaircraft.com
 
Hi. Thank you for your answer.
I use VBA (MS Word). FrmFounders is my form.
I create Frame Control named myFrame >dynamically<.
That is why, I think, this code doesn't work:

Code:
    Private Sub UserForm_Initialize()
    Dim MyFrame As Object
    Dim MyCmd As Object
    Set MyFrame = frmFounders.Controls.Add(&quot;Forms.Frame.1&quot;)
    With MyFrame
        .Name = &quot;MyFrame&quot;
        .Left = 20
        .Top = 20
        .Width = 40
        .Height = 50
        .Caption = &quot;&quot;
        .Visible = True
    End With
    Set MyCmd = frmFounders.MyFrame.Controls.Add(&quot;Forms.OptionButton.1&quot;)
    With MyCmd
        .Width = 15
        .Height = 10
        .Top = frmFounders.MyFrame.Height - .Height - 5
        .Left = frmFounders.MyFrame.Width - .Width - 5
    End With
End Sub
=> Compile error:
Set MyCmd = frmFounders.MyFrame.Controls.Add(&quot;Forms.OptionButton.1&quot;)
Method or data member not found (Error 461)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top