ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Suppressing events (https://www.excelbanter.com/excel-programming/322849-suppressing-events.html)

rci

Suppressing events
 
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

Ben

Suppressing events
 
application.enableevents = false

BIG NOTE be very sure to reenable events with application.enableevents =
true or else events will not function AT ALL.

"rci" wrote:

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


Tom Ogilvy

Suppressing events
 
Application.EnableEvents only works on Excel events, not on the events
associated with msforms control - a completely different library.

--
Regards,
Tom Ogilvy

"ben" wrote in message
...
application.enableevents = false

BIG NOTE be very sure to reenable events with application.enableevents =
true or else events will not function AT ALL.

"rci" wrote:

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




Tom Ogilvy

Suppressing events
 
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.


--
Regards,
Tom Ogilvy


"rci" wrote in message
...
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





All times are GMT +1. The time now is 05:25 AM.

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