Suppressing events

  • Thread starter Thread starter rci
  • Start date Start date
R

rci

Hi all...


I am changing the value of a checkbox in code... and I need to suppress the
click event when doing so. How might I do this?

In other words, changing the value of a checkbox triggers the .click event,
and I need to prevent this...

Thanks!

M
 
application.enableevents = false

BIG NOTE be very sure to reenable events with application.enableevents =
true or else events will not function AT ALL.
 
Application.EnableEvents only works on Excel events, not on the events
associated with msforms control - a completely different library.
 
One technique is to declare a public variable at the top of a general module

Public bBlockEvents as Boolean

then in the click event of the control

Private Sub Checkbox1_Click()
if bBlockEvents then exit sub
' you current code
End Sub

Then in the code that would trigger the event

bBlockEvents = True
' code that would trigger the event
bBlockEvents = False

so anytime you want to block events, set the flag (bBlockEvents) to true

Every event procedure (that you want to be able to block) must check the
value of the flag as the first thing and exit if it is true.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top