Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

SelLength update on textbox only works in debug

Avatar of shambalad
shambaladFlag for United States of America asked on
Microsoft Access
3 Comments1 Solution295 ViewsLast Modified:
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.
Thanks,
Todd
Private Sub txtDate_GotFocus()
      Dim ctl As Control
      Set ctl = Screen.ActiveControl
      With ctl
      If IsDate(ctl) Then
            .SelStart = 0
            .SelLength = 8
         End If
      End With
   End Sub
ASKER CERTIFIED SOLUTION
Avatar of mildurait
milduraitFlag of Australia image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers