I have the following code set for when my text box 'txtDate' gets focus. The date is formatted as "mm/dd/yy".
When I run this subroutine in debug, breaking on the line after the one that references the 'Screen.ActiveControl', this routine works (i.e. the text in the text box is entirely selected). If I clear all breakpoints and then just click on the control, the cursor is positioned at the beginning of the text box and the text is not selected. Why is this happening?
There is a date value loaded in the field (e.g. "02/26/09") when the control gets focus.
Private Sub txtDate_GotFocus()
Dim ctl As Control
Set ctl = Screen.ActiveControl
If IsDate(ctl) Then
.SelStart = 0
.SelLength = 8