Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Move cursor to textbox in a userform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jgmiddel - 29 Mar 2006 13:44 GMT
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
Martin - 29 Mar 2006 13:59 GMT
TextBox1.SetFocus

> Hi, I would like to check (on Exit) a value entered in a textbox with a
>
[quoted text clipped - 6 lines]
>
> Thanks in advance!
Tom Ogilvy - 29 Mar 2006 14:10 GMT
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.

Signature

Regards,
Tom Ogilvy

> Hi, I would like to check (on Exit) a value entered in a textbox with a
>
[quoted text clipped - 6 lines]
>
> Thanks in advance!
papou - 29 Mar 2006 14:19 GMT
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
jgmiddel - 29 Mar 2006 14:40 GMT
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
jgmiddel - 29 Mar 2006 14:55 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.