Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can't see cursor or selected text in textbox even though it has fo

I have a textbox on a userform that is validated before updating. The
problem is that after an invalid date is entered by the user, the focus
returns to the textbox but it is not activated--i.e., no keyboard input is
accepted except the tab key and shift tab. I want the textbox selected or a
cursor present so that the user can reenter data into the textbox. (By the
way, the routine below works the same even when omitting the lines containing
SelStart, SelLength, and SetFocus.)

Private Sub StartDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)

Dim mytext As String

mytext = CheckDateEntry(StartDate)
If mytext = "invalid" Then
Cancel = True
StartDate.SelStart = 0
StartDate.SelLength = Len(StartDate.Text)
StartDate.SetFocus
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Can't see cursor or selected text in textbox even though it has fo

Code worked OK for me.

--
Regards,
Tom Ogilvy

"KHanna" wrote in message
...
I have a textbox on a userform that is validated before updating. The
problem is that after an invalid date is entered by the user, the focus
returns to the textbox but it is not activated--i.e., no keyboard input is
accepted except the tab key and shift tab. I want the textbox selected or

a
cursor present so that the user can reenter data into the textbox. (By

the
way, the routine below works the same even when omitting the lines

containing
SelStart, SelLength, and SetFocus.)

Private Sub StartDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)

Dim mytext As String

mytext = CheckDateEntry(StartDate)
If mytext = "invalid" Then
Cancel = True
StartDate.SelStart = 0
StartDate.SelLength = Len(StartDate.Text)
StartDate.SetFocus
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Can't see cursor or selected text in textbox even though it ha

Tom,

Thanks for the reply. My problem was that I opened the form with the
parameter "vbmodeless". After removing it, it works fine.

"Tom Ogilvy" wrote:

Code worked OK for me.

--
Regards,
Tom Ogilvy

"KHanna" wrote in message
...
I have a textbox on a userform that is validated before updating. The
problem is that after an invalid date is entered by the user, the focus
returns to the textbox but it is not activated--i.e., no keyboard input is
accepted except the tab key and shift tab. I want the textbox selected or

a
cursor present so that the user can reenter data into the textbox. (By

the
way, the routine below works the same even when omitting the lines

containing
SelStart, SelLength, and SetFocus.)

Private Sub StartDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)

Dim mytext As String

mytext = CheckDateEntry(StartDate)
If mytext = "invalid" Then
Cancel = True
StartDate.SelStart = 0
StartDate.SelLength = Len(StartDate.Text)
StartDate.SetFocus
End If
End Sub




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
Highlight all Text in a Textbox when the textbox is selected RPIJG[_73_] Excel Programming 3 October 28th 05 08:28 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
getting the cursor to show in a textbox Simon Lloyd[_495_] Excel Programming 2 June 21st 04 06:59 PM
cursor selected range from a text box Pal Excel Programming 2 January 23rd 04 12:07 PM


All times are GMT +1. The time now is 02:59 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"