ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Load a ComboBox without triggering another event (https://www.excelbanter.com/excel-programming/388974-load-combobox-without-triggering-another-event.html)

dan

Load a ComboBox without triggering another event
 
I have two combo boxes. One is loaded at run time.
The second is loaded with values that depend on the user's selection in the
first one.

So the ComboBox2 should load values only after the USER selects something in
ComboBox1.

When the program is loading ComboBox1, it appears to trigger ComboBox2. I
have tried the ComboBox1_change() and ComboBox1_Click() events, but they
don't work.

I hope that makes sense...

How can I prevent ComboBox2's event from firing while combobox1 is being
loaded, but allow it to run once the user makes a selection from combobox1?

Thanks!
dan

Gary''s Student

Load a ComboBox without triggering another event
 
create a global, static boolean in a standard module. something like

arewethereyet

arewethereyet should be initialized to False.
ComboBox2 code should always examine arewethereyet and immediately exit if
it False. This will dismiss any accidental tripping of ComboBox2.

Have the ComboBox1 code set arewethereyet to True as the last thing it does.
This will allow ComboBox2 to run in the proper, subsequent, fashion.
ComboBox2 code should also restore arewethereyet to False prior to exit.
--
Gary''s Student - gsnu200719


"Dan" wrote:

I have two combo boxes. One is loaded at run time.
The second is loaded with values that depend on the user's selection in the
first one.

So the ComboBox2 should load values only after the USER selects something in
ComboBox1.

When the program is loading ComboBox1, it appears to trigger ComboBox2. I
have tried the ComboBox1_change() and ComboBox1_Click() events, but they
don't work.

I hope that makes sense...

How can I prevent ComboBox2's event from firing while combobox1 is being
loaded, but allow it to run once the user makes a selection from combobox1?

Thanks!
dan


dan

Load a ComboBox without triggering another event
 
So simple, so elegant, and works perfect!
Thanks a bunch.
dan

"Gary''s Student" wrote:

create a global, static boolean in a standard module. something like

arewethereyet

arewethereyet should be initialized to False.
ComboBox2 code should always examine arewethereyet and immediately exit if
it False. This will dismiss any accidental tripping of ComboBox2.

Have the ComboBox1 code set arewethereyet to True as the last thing it does.
This will allow ComboBox2 to run in the proper, subsequent, fashion.
ComboBox2 code should also restore arewethereyet to False prior to exit.
--
Gary''s Student - gsnu200719


"Dan" wrote:

I have two combo boxes. One is loaded at run time.
The second is loaded with values that depend on the user's selection in the
first one.

So the ComboBox2 should load values only after the USER selects something in
ComboBox1.

When the program is loading ComboBox1, it appears to trigger ComboBox2. I
have tried the ComboBox1_change() and ComboBox1_Click() events, but they
don't work.

I hope that makes sense...

How can I prevent ComboBox2's event from firing while combobox1 is being
loaded, but allow it to run once the user makes a selection from combobox1?

Thanks!
dan



All times are GMT +1. The time now is 05:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com