Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stay in TextBox

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default SV: Stay in TextBox

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default SV: Stay in TextBox

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
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
Calculate Textbox value based on another textbox value.doc Tdungate Excel Discussion (Misc queries) 1 February 12th 09 07:11 PM
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
How do I get my formula to stay the same BertiesMum New Users to Excel 4 November 20th 05 04:00 PM
Autofit does not stay on. Karen Excel Discussion (Misc queries) 0 October 26th 05 05:02 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 04:36 PM.

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"