Can't see cursor or selected text in textbox even though it has fo

G

Guest

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
 
G

Guest

Tom,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top