set Behaviour entering field programatically

G

Guest

Hey, I noticed this was addressed in a previous post but i need a little more
specific help, namely:
the Option for Behaviour Entering Field can be set using
Application.SetOption("Behavior Entering Field") = 0

What I have is a form with many text and combo boxes. for the most patr, i
want the behavious set to Select Entire Field. There is one text box where I
need to change it so on entering it moves to the end of the field, then
changes back once I exit the field. I tried putting the code in OnExit and
OnEnter but i get a "Compile Error: Argument not optional" error. What am i
doing wrong?
 
D

Dirk Goldgar

In
aft3rgl0w said:
Hey, I noticed this was addressed in a previous post but i need a
little more specific help, namely:
the Option for Behaviour Entering Field can be set using
Application.SetOption("Behavior Entering Field") = 0

What I have is a form with many text and combo boxes. for the most
patr, i want the behavious set to Select Entire Field. There is one
text box where I need to change it so on entering it moves to the end
of the field, then changes back once I exit the field. I tried
putting the code in OnExit and OnEnter but i get a "Compile Error:
Argument not optional" error. What am i doing wrong?

Rather than changing the global setting, you can do this quite simply
with code in the GotFocus event of that particular control. For
example:

Private Sub txtNotes_GotFocus()

With Me!txtNotes
.SelStart = Len(.Text)
End With

End Sub
 

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