ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to prevent and event? (https://www.excelbanter.com/excel-programming/434446-how-prevent-event.html)

SMS

How to prevent and event?
 
In a textbox.afterupdate() event, I have a line to make the
textbox.visible FALSE. This triggers another afterupdate event. How
do I suppress this?

Private Sub TextBox1_afterupdate()
TextBox1.Text = ""
TextBox1.Visible = False
End Sub

Thank you!

Bob Umlas[_3_]

How to prevent and event?
 
Private Sub TextBox1_afterupdate()
dim NotNow as boolean
If Notnow then exit sub
NotNow = true
TextBox1.Text = ""
TextBox1.Visible = False
NotNow = False
End Sub

"SMS" wrote in message
...
In a textbox.afterupdate() event, I have a line to make the
textbox.visible FALSE. This triggers another afterupdate event. How
do I suppress this?

Private Sub TextBox1_afterupdate()
TextBox1.Text = ""
TextBox1.Visible = False
End Sub

Thank you!




Per Jessen

How to prevent and event?
 
Hi

Turn off events before you manipulate the textbox, just remember to turn it
on again.

Private Sub TextBox1_afterupdate()
Application.EnableEvents=False
TextBox1.Text = ""
TextBox1.Visible = False
Application.EnableEvents=True
End Sub

Regards,
Per

"SMS" skrev i meddelelsen
...
In a textbox.afterupdate() event, I have a line to make the
textbox.visible FALSE. This triggers another afterupdate event. How
do I suppress this?

Private Sub TextBox1_afterupdate()
TextBox1.Text = ""
TextBox1.Visible = False
End Sub

Thank you!



Bob Umlas[_3_]

How to prevent and event?
 
That won't work -- events are not "events" as far as userforms are
concerned, and if you step thru the code you'll see it fires again. My
original code did have an error, however; the variable NotNow needs to be
dimmed at the top of the module, not inside the sub:

dim NotNow as boolean
Private Sub TextBox1_afterupdate()
If Notnow then exit sub
NotNow = true
TextBox1.Text = ""
TextBox1.Visible = False
NotNow = False
End Sub


"Per Jessen" wrote in message
...
Hi

Turn off events before you manipulate the textbox, just remember to turn
it on again.

Private Sub TextBox1_afterupdate()
Application.EnableEvents=False
TextBox1.Text = ""
TextBox1.Visible = False
Application.EnableEvents=True
End Sub

Regards,
Per

"SMS" skrev i meddelelsen
...
In a textbox.afterupdate() event, I have a line to make the
textbox.visible FALSE. This triggers another afterupdate event. How
do I suppress this?

Private Sub TextBox1_afterupdate()
TextBox1.Text = ""
TextBox1.Visible = False
End Sub

Thank you!





SMS

How to prevent and event?
 
Thanks for the workaround... it is interesting that events on a
userform are somehow different. I wonder if there is an easy way to
understand the descrepancies between the UFs and the standard sheets
wrt events.



On Oct 2, 10:37*am, "Bob Umlas" wrote:
That won't work -- events are not "events" as far as userforms are
concerned, and if you step thru the code you'll see it fires again. My
original code did have an error, however; the variable NotNow needs to be
dimmed at the top of the module, not inside the sub:

dim NotNow as boolean
Private Sub TextBox1_afterupdate()
* * If Notnow then exit sub
* * NotNow = true
* * TextBox1.Text = ""
* * TextBox1.Visible = False
* * NotNow = False
*End Sub

"Per Jessen" wrote in message

...



Hi


Turn off events before you manipulate the textbox, just remember to turn
it on again.


Private Sub TextBox1_afterupdate()
Application.EnableEvents=False
* *TextBox1.Text = ""
* *TextBox1.Visible = False
Application.EnableEvents=True
End Sub


Regards,
Per


"SMS" skrev i meddelelsen
....
In a textbox.afterupdate() event, I have a line to make the
textbox.visible FALSE. *This triggers another afterupdate event. *How
do I suppress this?


Private Sub TextBox1_afterupdate()
* *TextBox1.Text = ""
* *TextBox1.Visible = False
End Sub


Thank you!- Hide quoted text -


- Show quoted text -




All times are GMT +1. The time now is 09:17 AM.

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