SetFocus Problem

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

My original question was...What is the code to enter lets
say TextBox6. When I say this, I want the cursor to enter
that textbox.

Robin Hammond said to use setfocus

textbox6.setfocus

When I do this it does not work. The way I did it was
entering a value in textbox6 and clicking in another
textbox, if a certain condition is met a msgbox pops up
telling the user invalid value and then the next line is
textbox6.setfocus to bring the cursor back in that
textbox, but instead, the cursor goes to the textbox I
clicked.

How do I fix this?

Thank you

Todd Huttenstine
 
Todd,

This works for me

With TextBox6
.SetFocus
.SelStart 1
.SelLength = Len(.Text)
Cancel = True
End With

I use this code in the Textbox Exit event, as this has the option to cancel
an exit.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thank you that did it.

-----Original Message-----
Todd,

This works for me

With TextBox6
.SetFocus
.SelStart 1
.SelLength = Len(.Text)
Cancel = True
End With

I use this code in the Textbox Exit event, as this has the option to cancel
an exit.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




.
 
Back
Top