View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default ComboBox.Clear method calling ComboBox_Change event?

If you don't want users to be able to type in values that are not in the
combo box list, you can set the combo box style to frmStyleDropDownList.

When you clear the combo box list and the combo box currently has a selected
value, the Change event will fire. To avoid executing your code in the
change event, maybe you can exit out of the sub if the combo box has no value
selected. For example:

Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = -1 Then Exit Sub

'put your code below
End Sub


--
Hope that helps.

Vergel Adriano


"Clayman" wrote:

I need to clear out a ComboBox in order to prep it for later use. At the
current time, it has 200 entries. Eventually it will have over 2000. Removing
each item individually is not a desirable option. It takes a while to load
it. I'd hate for it to take that long to unload.

Problem is, when I execute ComboBox.Clear, it appears to call the
ComboBox_Change() event. Since there is nothing in the ComboBox, it calls the
error handler that checks for unknown entries (ie: typing your own data in
the BomboBox).

Is there a way to execute the .Clear method without calling the _Change()
event?
--
Adios,
Clay Harryman