Results 1 to 3 of 3

Thread: VBA question

  1. #1
    Join Date
    Aug 2003

    Angry Unanswered: VBA question

    I wonder if a control on a form can be created dynamically.
    Say, you click a button and a list box will show up or all the controls MUST be created in form's design view?

    Dim ctlListBox As New ListBox
    ' ctlListBox.Properties ... specify coords, size, record source and so forth
    ctlListBox.Visible = True

    gives me 'ActiveX component can't create object' error.

    Thanks it, gimme a beer... Jimi Hendrix RULES!

  2. #2
    Join Date
    Oct 2003

    are u perhaps referring of pressing a button, and then showing alist box on a form?

    cause thats realllllllllll easy

    on a form create a button and call it lets say:


    and a listbox named by:

    click on the list1 and make it invisible:
    left click on the list1 control and choose properties
    on the format tab, select the visible option, left click and choose no

    in the click event of the button write this

    Private Sub Command0_Click()
    Me.List1.Visible = True

    End Sub

    after press on button the list1 show on the form

    if this is not what u mean then u have 2 wait for a better reply,
    if it is, well then i am very happy 4 u


  3. #3
    Join Date
    Oct 2003
    I don't think you can create a new control on-the-fly, I think it has to be done at design time. You can create a control at design time and hide it by making the visible property = false and then when needed make it visible. So when the user click on a button it makes the listbox if you figure out how to generate one dynamically...good luck.

Posting Permissions

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