K
KHanna
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
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