Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Add the text box Exit event to your form:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If (TextBox1.Text = "invalid input") Then Cancel = True End If End Sub If you set Cancel to true the cursor is not moved out of the text box. -----Original Message----- In a Form I have a TextBox. When I leave the textBox, I run a validation of the input. What I need is to stay in the TextBox, whenever the validation goes wrong. In another way whenever the user tab out of the TextBox, or click on another TextBox in the Form, the Curser must jump back... or even better... not leave the actual TextBox. How to??? . |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It works great if I tab out of the TextBox, or if I click another TextBox
But if I click a Button on the Form, no error happens. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the exit events is not triggered by code.
alternative: Option Explicit Private Sub TextBox1_Change() If Me.ActiveControl Is Me.TextBox1 Then Exit Sub Me.Label1 = Me.TextBox1 End Sub Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Me.Label1 = Me.TextBox1 End Sub hth keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool ?B?YWt5aG5l?= wrote: It works great if I tab out of the TextBox, or if I click another TextBox. But if I click a Button on the Form, no error happens. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculate Textbox value based on another textbox value.doc | Excel Discussion (Misc queries) | |||
Calculate Textbox value based on another textbox value | Excel Discussion (Misc queries) | |||
How do I get my formula to stay the same | New Users to Excel | |||
Autofit does not stay on. | Excel Discussion (Misc queries) | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming |