View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Umlas[_3_] Bob Umlas[_3_] is offline
external usenet poster
 
Posts: 320
Default 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!