View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Disabling events within an event handler

This isn't an event to excel. So you have to take care of it yourself.

Option Explicit
Public BlkProc As Boolean
private sub Combobox1_Change()
if blkproc = true then exit sub
do stuff
blkproc = true
Combobox2.Text = "something"
blkproc = false
end sub

private sub Combobox2_change()
if blkproc = true then exit sub
do stuff
blkproc = true
Combobox1.Text = "the other thing"
blkproc = false
end sub

feltra wrote:

Hi,

I have 2 comboboxes created from the Control Toolbox. I want to set
the text of one combobox when the other is clicked. Here's a sample
code for the Change event for them. (line numbers are given for easy
reference - they dont exist in the code)

1 private sub Combobox1_Change()
2 do stuff
3 Combobox2.Text = "something"
4 end sub
5
6 private sub Combobox2_change()
7 do stuff
8 Combobox1.Text = "the other thing"
9 end sub

In the above, when Combobox1_Change() is executing, I do not want it
to go to Combobox2_change()... This is happening. I then replaced
line 3 with the following:
Application.EnableEvents = False
Combobox2.Text = "something"
Application.EnableEvents = True

Well, the problem continues. I tired other things like setting
Combobox1.Application.Events flag. Same result. It just does not
seem to ignore the Change event for Combobox2.

How do I make this happen?

Thanks a lot for any pointers & Best Regards,
-feltra


--

Dave Peterson