Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamically createing text boxes in Userforms (Excel 2000)

    I need to dynamically create objects in a userform. For example. I need to create a number of text boxes based off the value in another text box. This number is potentially too large to just create say 100 text boxes and use the invisible property.

    Mike

  2. #2
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dynamically createing text boxes in Userforms (Excel 2000)

    The user form would not look very "user friendly" if there were to be 150 text boxes positioned on it. What is the idea for having so many text boxes. Would it not be viable to hace combo boxes with dropdown values, or use a different approach as a solution??
    Regards,
    Rudi

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Dynamically createing text boxes in Userforms (Excel 2000)

    Here is a simple example; you can adapt it got your needs.

    Sub CreateTextBoxes()
    Dim i As Integer
    For i = 1 To 10
    With UserForm1.Controls.Add("Forms.TextBox.1", _
    "txtText" & i, True)
    .Top = 18 * i + 12
    .Left = 12
    .Width = 72
    .Height = 12
    End With
    Next i
    End Sub

    All measurements are in points (1 inch = 72 points). Look up Add in the online help for more info.

    Note: Rudi is correct, hundreds of text boxes are not user-friendly.

  4. #4
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dynamically createing text boxes in Userforms (Excel 2000)

    That should work fine. How would I do the same thing in a form in Access?

    Mike

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Dynamically createing text boxes in Userforms (Excel 2000)

    You'd best ask that in a new thread in Access, since Access forms are very different from UserForms in Excel.

  6. #6
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Lexington Park, Maryland, USA
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dynamically createing text boxes in Userforms (Excel 2000)

    This works on a userform. how do you do this in a Multi-page in a userform?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Dynamically createing text boxes in Userforms (Excel 2000)

    Each Page in a MultiPage control has its own Controls collection. For example:

    Set MyTextBox = Me.MultiPage1.Pages(0).Controls.Add("MSForms.TextB ox.1", "MyTextBox")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •