![]() |
ComboBox.Clear method calling ComboBox_Change event?
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 |
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 |
ComboBox.Clear method calling ComboBox_Change event?
The code sample will work well.
I was afraid to try "frmStyleDropDownList", thinking it would force the users to click and scroll through up to 2000 items. But it worked quite well! Thank you! -- Adios, Clay Harryman "Vergel Adriano" wrote: 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 |
All times are GMT +1. The time now is 03:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com