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

How to stop Event Procedure from executing

Status
Not open for further replies.

SgtPepps

IS-IT--Management
May 1, 2002
109
GB
Hello, i'd like to - ComboBox.clear - without the 'ComboBox_Change' event procedure running. I only want the 'ComboBox_Change' event procedure to run when i add an item to the ComboBox. Is there a way i can specify this when i do - ComboBox.Clear? or when i do ComboBox.AddItem?

Thanks

Mike

Hold the Wheel and drive
 
You can use AfterUpdate event - it fires only when control's value is changed via user's interface.

combo
 
I don't think you stop the event from firing, but one approach is to use a flag to control execution of the code inside the event.
Code:
Private Sub ComboBox_Change ()
   If (Exec_Change_Code) Then
      ...
   End If
End Sub
Initialize Exec_Change_Code to true in the Form Load, and then when you want to clear.
Code:
Exec_Change_Code = False
ComboBox.Clear
Exec_Change_Code = True

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Surely it is as simple as having this as the 1st line of code in your change event sub


If Combobox = "" then exit sub

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Right on the money Geoff (as always) ;-)

That would have been my suggestion as well!



[santa] Happy Ho Ho!!! [Cheers]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
See Mike - I even left out the .value - just for you ;-)

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Combo & CajunCenturion, thankyou, tests suggest that both of these will work.

xlbo, I believe that i've not supplied you with enough information.

I have 4 ComboBoxs, combo 1 is filled during the form.activate. It is filled with all values on a list (Actually a list of all directories on root of Drive of choice).

Pick a directory name from the first combo, combo 2 gets populated with all sub-directories.

Pick directory name from combo 2, combo 3 gets populated with all sub-directories. and so on.........

But, if i've already changed all combo values, and would then like to change the first one again, things go wrong. Its because the combo1 change sub includes code to clear all other combos, then re-populate combo2 dependant on which dir is chosen. combo 2 includes the same code but doesn't clear combo1, only combo 3 & 4, combo3 only clears combo 4. The word "Cascade" springs to mind.

So, as soon as combo1 is changed for the second time then tries to clear combo2, the combo2 sub is run, cascading all the way down the line.

I'm sure that your suggestion will work in some respect but i don't have the time/brain power to understand the logic quite that well so i try to use Standard Functions and things as often as possible.

If i've explained it well enough and you have more suggestions, i'm open.

Thank You all for your time!

Mike

Hold the Wheel and drive
 
This is how I would try to explain Geoff's suggestion with your example:
Code:
Private Sub ComboBox1_Change()
ComboBox2.Clear
ComboBox3.Clear
ComboBox4.Clear
' Update ComboBox2 based on
' ComboBox1 Value Macro
End Sub

Private Sub ComboBox2_Change()
If ComboBox1 = "" Then Exit Sub
ComboBox3.Clear
ComboBox4.Clear
' Update ComboBox3 based on
' ComboBox1 Value Macro
End Sub

Private Sub ComboBox3_Change()
If ComboBox2 = "" Then Exit Sub
ComboBox4.Clear
' Update ComboBox4 based on
' ComboBox3 Value Macro
End Sub

Private Sub ComboBox4_Change()
If ComboBox3 = "" Then Exit Sub
' No Update necessary
End Sub
Or did I miss something too?



[santa] Happy Ho Ho!!! [Cheers]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Thank You very much, I'll try that soon.

who missed something, i don't understand. xlbo replied to my original post then i elaborated on my request.

I like these forums, the people who use them are very helpfull! Please let me know if i've been rude in some way because i don't want to be again.

Thank You

Mike S

Hold the Wheel and drive
 
I wasn't trying to insinuate(sp?) that you were being rude SgtPepps, I was just trying to make sure that I understood your elaboration correctly ;-)

Glad you like it here. So do I. [thumbsup2]



[santa] Happy Ho Ho!!! [Cheers]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Ta Mike - I do like it when you do my work for me !!!
[cheers]

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Always here to help Geoff, but now I'm going home!

Merry Ho Ho (XMas) to all and to all a good night!!

[cheers]



[santa] Happy Ho Ho!!! [Cheers]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
I ended up doing as xlbo & Bowyers74 suggested but quering a boolean variable rather than the combobox.value as suggested by CajunCenturion.

ThankYou All!!

Hold the Wheel and drive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top