Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default suspend processing for TextBox_Change events when initializing a f

I have a form with multiple textboxes. When initializing the form, I use
values from the worksheet to fill the textboxes. Each of these
initialization steps triggers the TextBox_Change event, which is unnecessary
during the initialization. Can I easily stop the TextBox_Change event during
this initialization?

The code following works, but seems a little bulky and I would prefer
something more efficient or eloquent. Oh, and it's a pain to have to write
the TextBox_Change code over and over for multiple textboxes.

What I have done is this (with x being a public variable):
x = false
....code that triggers Textbox_Change
x=true

Textbox_Change
If x = true then
....code
Else
'do nothing
End If

Thanks,
drhalter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default suspend processing for TextBox_Change events when initializing a f

That's basically what you have to do. I usually scope my variable to the
code module. I also call it bEnableEvents to mimic the
Application.EnableEvents property which doesn't affect UserForm events.

If you like, you could even use Application.EnableEvents, and do your
UserForm event procedures this way:

Private Sub Textbox1_Change()
If Application.EnableEvents Then
' your code goes here
End If
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"drhalter" wrote in message
...
I have a form with multiple textboxes. When initializing the form, I use
values from the worksheet to fill the textboxes. Each of these
initialization steps triggers the TextBox_Change event, which is
unnecessary
during the initialization. Can I easily stop the TextBox_Change event
during
this initialization?

The code following works, but seems a little bulky and I would prefer
something more efficient or eloquent. Oh, and it's a pain to have to
write
the TextBox_Change code over and over for multiple textboxes.

What I have done is this (with x being a public variable):
x = false
...code that triggers Textbox_Change
x=true

Textbox_Change
If x = true then
...code
Else
'do nothing
End If

Thanks,
drhalter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default suspend processing for TextBox_Change events when initializing

Wow, that's a pain. I even have some code listed now
If x = true then
x = false
...code (which would trigger another TextBox_Change event, but
since x is false, it skips the code)
x = true
End If

Thanks for the info!
drhalter

"Jon Peltier" wrote:

That's basically what you have to do. I usually scope my variable to the
code module. I also call it bEnableEvents to mimic the
Application.EnableEvents property which doesn't affect UserForm events.

If you like, you could even use Application.EnableEvents, and do your
UserForm event procedures this way:

Private Sub Textbox1_Change()
If Application.EnableEvents Then
' your code goes here
End If
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"drhalter" wrote in message
...
I have a form with multiple textboxes. When initializing the form, I use
values from the worksheet to fill the textboxes. Each of these
initialization steps triggers the TextBox_Change event, which is
unnecessary
during the initialization. Can I easily stop the TextBox_Change event
during
this initialization?

The code following works, but seems a little bulky and I would prefer
something more efficient or eloquent. Oh, and it's a pain to have to
write
the TextBox_Change code over and over for multiple textboxes.

What I have done is this (with x being a public variable):
x = false
...code that triggers Textbox_Change
x=true

Textbox_Change
If x = true then
...code
Else
'do nothing
End If

Thanks,
drhalter




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default suspend processing for TextBox_Change events when initializing

Quick hint:

Instead of

If x = true then

you could simply use

If x then

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"drhalter" wrote in message
...
Wow, that's a pain. I even have some code listed now
If x = true then
x = false
...code (which would trigger another TextBox_Change event, but
since x is false, it skips the code)
x = true
End If

Thanks for the info!
drhalter

"Jon Peltier" wrote:

That's basically what you have to do. I usually scope my variable to the
code module. I also call it bEnableEvents to mimic the
Application.EnableEvents property which doesn't affect UserForm events.

If you like, you could even use Application.EnableEvents, and do your
UserForm event procedures this way:

Private Sub Textbox1_Change()
If Application.EnableEvents Then
' your code goes here
End If
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"drhalter" wrote in message
...
I have a form with multiple textboxes. When initializing the form, I
use
values from the worksheet to fill the textboxes. Each of these
initialization steps triggers the TextBox_Change event, which is
unnecessary
during the initialization. Can I easily stop the TextBox_Change event
during
this initialization?

The code following works, but seems a little bulky and I would prefer
something more efficient or eloquent. Oh, and it's a pain to have to
write
the TextBox_Change code over and over for multiple textboxes.

What I have done is this (with x being a public variable):
x = false
...code that triggers Textbox_Change
x=true

Textbox_Change
If x = true then
...code
Else
'do nothing
End If

Thanks,
drhalter






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
TextBox_Change a little premature! Post Tenebras Lux Excel Programming 4 September 4th 06 10:03 AM
suspend a routine Patrick Simonds Excel Programming 2 May 29th 06 10:18 PM
Suspend Execution Kaval Excel Programming 1 August 11th 05 09:21 AM
Suspend code John Excel Programming 0 August 18th 04 03:15 PM
Screen suspend eyecalibrate[_3_] Excel Programming 2 March 3rd 04 04:44 PM


All times are GMT +1. The time now is 10:07 AM.

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

About Us

"It's about Microsoft Excel"