Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Stop the _Change event? Is there EnableEvents for Forms?

I would like to be able to temporarily disable one of the _Change events in
my form because I don't want it to fire during, for example, the initialize
sub. I've tried several things including using the .enabled=false, and
..locked=false, and even Application.EnableEvents = False, ...but the _Change
event still fired. Here is the specific sub I want to temporarily disable.
It's for a textbox called CurrentPBox that calls a very involved Draw routine.

Private Sub CurrentPBox_click()
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, replace it with what had been there
End If
End Sub

Thanks!
-Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Stop the _Change event? Is there EnableEvents for Forms?

Set events to false. Then is the code you don't want to run

Private Sub CurrentPBox_click()
If application.EnableEvents = False then exit sub
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, replace it with what had been
there
End If
End Sub

EnableEvents only works on events in the Excel object module. However, you
can check its status in this event.

--
Regards,
Tom Ogilvy

"T_o_n_y" wrote in message
...
I would like to be able to temporarily disable one of the _Change events in
my form because I don't want it to fire during, for example, the
initialize
sub. I've tried several things including using the .enabled=false, and
.locked=false, and even Application.EnableEvents = False, ...but the
_Change
event still fired. Here is the specific sub I want to temporarily
disable.
It's for a textbox called CurrentPBox that calls a very involved Draw
routine.

Private Sub CurrentPBox_click()
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, replace it with what had been
there
End If
End Sub

Thanks!
-Tony



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Stop the _Change event? Is there EnableEvents for Forms?

I see that Tom has offered up a (quite novel) solution, but the way that I
do it is to maintain my own events Boolean, like so

Private fReEntry As Boolean

Private Sub CurrentPBox_click()
If Not fReEntry Then
fReEntry = True
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, _
store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, _
replace it with what had been there
End If
fReEntry = False
End If
End Sub


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"T_o_n_y" wrote in message
...
I would like to be able to temporarily disable one of the _Change events

in
my form because I don't want it to fire during, for example, the

initialize
sub. I've tried several things including using the .enabled=false, and
.locked=false, and even Application.EnableEvents = False, ...but the

_Change
event still fired. Here is the specific sub I want to temporarily

disable.
It's for a textbox called CurrentPBox that calls a very involved Draw

routine.

Private Sub CurrentPBox_click()
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, replace it with what had been

there
End If
End Sub

Thanks!
-Tony



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Stop the _Change event? Is there EnableEvents for Forms?

Tom,

That's clever.

Thanks.
-Tony

"Tom Ogilvy" wrote:

Set events to false. Then is the code you don't want to run

Private Sub CurrentPBox_click()
If application.EnableEvents = False then exit sub
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, replace it with what had been
there
End If
End Sub

EnableEvents only works on events in the Excel object module. However, you
can check its status in this event.

--
Regards,
Tom Ogilvy

"T_o_n_y" wrote in message
...
I would like to be able to temporarily disable one of the _Change events in
my form because I don't want it to fire during, for example, the
initialize
sub. I've tried several things including using the .enabled=false, and
.locked=false, and even Application.EnableEvents = False, ...but the
_Change
event still fired. Here is the specific sub I want to temporarily
disable.
It's for a textbox called CurrentPBox that calls a very involved Draw
routine.

Private Sub CurrentPBox_click()
If IsNumeric(CurrentPBox) And CurrentPBox <= CurrentPSpin.Max _
And CurrentPBox = CurrentPSpin.Min Then
pCurrentP = CurrentPBox 'if its a valid value, store the value & spin
CurrentPSpin = CurrentPBox
DrawPetal pCurrentP, p, m, s, pCor
pBox = pCurrentP
Else
CurrentPBox = pCurrentP 'if its invalid, replace it with what had been
there
End If
End Sub

Thanks!
-Tony




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with sub..._Change Jacob Excel Programming 5 October 10th 06 05:00 PM
enableevents in event codes R..VENKATARAMAN Excel Programming 2 April 27th 06 06:13 AM
Why _Change(ByVal Target As Range) Jim at Eagle Excel Programming 4 May 11th 05 07:36 PM
Application.EnableEvents = true, but no event fires Wexler Excel Programming 0 October 19th 04 06:08 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"