Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Move cursor to textbox in a userform


Hi, I would like to check (on Exit) a value entered in a textbox with

certain cell. That's not the problem, but I would like to find a metho
how
to move the cursor to the wrong entered value (so: back to tha
textbox).

The error is given in a MsgBox.

Thanks in advance

--
jgmidde
-----------------------------------------------------------------------
jgmiddel's Profile: http://www.excelforum.com/member.php...fo&userid=3271
View this thread: http://www.excelforum.com/showthread.php?threadid=52754

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Move cursor to textbox in a userform

TextBox1.SetFocus

"jgmiddel" wrote:


Hi, I would like to check (on Exit) a value entered in a textbox with a

certain cell. That's not the problem, but I would like to find a method
how
to move the cursor to the wrong entered value (so: back to that
textbox).

The error is given in a MsgBox.

Thanks in advance!


--
jgmiddel
------------------------------------------------------------------------
jgmiddel's Profile: http://www.excelforum.com/member.php...o&userid=32714
View this thread: http://www.excelforum.com/showthread...hreadid=527545


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Move cursor to textbox in a userform

Better to use the Exit Event of the Textbox to check the entry. Then if it
is improper, the Event has a Cancel variable. If you set this to False, the
textbox won't be exited. It sounds like you are probably already using
this event to popup a msgbox, so just set the Cancel variable to true.

--
Regards,
Tom Ogilvy


"jgmiddel" wrote:


Hi, I would like to check (on Exit) a value entered in a textbox with a

certain cell. That's not the problem, but I would like to find a method
how
to move the cursor to the wrong entered value (so: back to that
textbox).

The error is given in a MsgBox.

Thanks in advance!


--
jgmiddel
------------------------------------------------------------------------
jgmiddel's Profile: http://www.excelforum.com/member.php...o&userid=32714
View this thread: http://www.excelforum.com/showthread...hreadid=527545


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Move cursor to textbox in a userform

Hello
In addition, you could highlight the whole (wrong)entry with:
With Me.TextBox1
..SelStart = 0
..SelLength = Len(.Value)
..SetFocus
End With

HTH
Cordially
Pascal


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Move cursor to textbox in a userform


Tom,

The data must be proceeded in a worksheet, so I use this:

Private Sub naam1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Range("Werkblad!A12") < 3 Then
Dim Msg, Style, Title, Response
Msg = Range("error1").Value
Style = vbInformation
Title = Range("naam").Value
Response = MsgBox(Msg, Style, Title)
On Error Resume Next
Userform.naam1.SetFocus
End If
End Sub

You say, the exit can be canceled. What I made doesn't work

--
jgmidde
-----------------------------------------------------------------------
jgmiddel's Profile: http://www.excelforum.com/member.php...fo&userid=3271
View this thread: http://www.excelforum.com/showthread.php?threadid=52754



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Move cursor to textbox in a userform


Done!
Private Sub naam1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Range("Werkblad!A12") < 3 Then
Dim Msg, Style, Title, Response
Msg = Range("error1").Value
Style = vbInformation
Title = Range("naam").Value
Response = MsgBox(Msg, Style, Title)
On Error Resume Next
Cancel = True
End If
End Su

--
jgmidde
-----------------------------------------------------------------------
jgmiddel's Profile: http://www.excelforum.com/member.php...fo&userid=3271
View this thread: http://www.excelforum.com/showthread.php?threadid=52754

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
move cursor on one sheet moves cursor on all sheets tdworden Excel Discussion (Misc queries) 2 July 22nd 07 10:50 PM
Userform - Move to next textbox field by hitting enter instead of TimT Excel Programming 12 November 2nd 05 09:06 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
How to move cursor from one textbox control to another textbox con KMoore007 Excel Programming 0 September 16th 04 02:47 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 12:57 AM.

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

About Us

"It's about Microsoft Excel"