Unexpected output while populating a combo box

S

shivboy

Hi,

I am making a userform in Excel. In the userform, I have a multipage in
which on the loading of the form, I would want to see the combo box
populate itself. I am using the following code:


Code:
--------------------

Private Sub MultiPage1_Change()
With cbDataType
.AddItem ("----- Select Data Type -----")
.AddItem ("Text")
.AddItem ("Memo")
.AddItem ("Number")
.AddItem ("Date/Time")
.AddItem ("Currency")
.AddItem ("AutoNumber")
.AddItem ("Yes/No")
End With
End Sub

--------------------


When I do that, what happens is that the combo box does get populated
but everytime I switch back and forth between this Page (in which the
combo box is placed) and other pages, the list of items multiply. If I
switch between the pages thrice, the above items will appear thrice in
the combo box. I understand that this is because of the "change" event
of the multipage, but then what should I be doing to prevent that from
happening?

Please help.

Regards,

Shivboy
 
C

colofnature

Either populate the combobox in the _Initialise event of the form, or
use

cbDataType.clear

in the MultiPage1_Change event before adding in the entries.


Col
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top