(Solved) – More entries in combo box with every call

  • by
(solved)-–-more-entries-in-combo-box-with-every-call

I have a collection CourtCollection and a userform UserFormTest which includes combobox CbbCourt. I want to populate the combobox with data from the collection and then show the userform. Here’s the code:

Sub RunUserForm()

    'Create the exemplar of the form
    Set Form1 = New UserFormTest

    'Add entries to the combo box from the collection
    For Each Item In CourtCollection
        Form1.CbbCourt.AddItem Item.Item("CourtName")
    Next Item
    Form1.CbbCourt.ListIndex = 1

    Form1.Show vbModeless

End Sub

As a result the combobox contains “item1, item2, item3” on the first userform call, “item1, item2, item3 item1, item2, item3” on the second e.t.c. I understand that it’s the exemplar of the userform which persists between calls despite me using New keyword in Set Form1 = New UserFormTest. I tried to put the code into the event UserFormTest_Initialize() but the userform can’t “see” my collection. What’s wrong and what change should I implement?

Leave a Reply

Your email address will not be published. Required fields are marked *