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

VBA Combobox AddItem annoyance..

Status
Not open for further replies.

basepointdesignz

Programmer
Jul 23, 2002
566
GB
Hi guys and gals,

Is there any other way or event for triggering the adding of items to a combobox in VBA? I'm writing a program for my work and I have two comboboxes that are filled with the current drawing's block names. The block names are added using the FormLoad (or in VBA) the UserForm_Activate event. This works fine but for one problem.....

I have a GetPoint command set up to obtain the origin point for the insertion point (for the blocks). This obviously causes the form to be hidden to first obtain the coordinates. whenever the form is hidden and then shown again the Userform_Activate event is triggered and another set of block names is added to the list, so now the list is twice as long with duplicate block names. This again happens if the form is hidden and shown again - adding another set of the names to the list....and so on.

I've tried RemoveItem using the userform_Deactivate event to remove all the items so that the Activate event will add them again - well, that didn't work.

Does anyone know what could be causing this problem or even how to remedy it. In VB there is a List property for the Combbox, so you can add the items at Design Time, but in VBA this property is not available - Aaaaarghhh!!

Thanks in advance..

Renegade..
 
You are retriggering the event, but you probably know this. Try using a USERFORM_INITIALIZE to fill the ComboBox because the initialize event does not get retriggered (is that a word) again. Good luck

BU
 
Thanks Borgunit,

That worked a treat! It adds the block names to the list - and only once too!!!

Cheers mate,

Renegade..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top