key press

L

Lior Montia

Hi,

what is the command the press the home button.
I want that every time a text box got focus automatically the cursor goes to
the first char in the box.

thanks.
 
S

strive4peace

if you always want the cursor to be at the start of the field, you may
wish to change the default behavior

Tools, Options, Keyboard

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
L

Lior Montia

no, I want only in this field when it got focus instead the user will press
the home button that it will happened automatically
 
S

storrboy

no, I want only in this field when it got focus instead the user will press
the home button that it will happened automatically


To change the cursor position to the start of the textbox when it
receives focus...

Private Sub TexBoxNamer_GotFocus()
Me!Text0.SelStart = 0
Me!Text0.SelLength = 0
End Sub
 
L

Lior Montia

It doesn't work.
maybe because the text box got focus by pressing in with the mouse and not
by pressing TAB in the keyboard ?
 
S

storrboy

It doesn't work.
maybe because the text box got focus by pressing in with the mouse and not
by pressing TAB in the keyboard ?


Shouldn't matter.
Did you change the names of the controls in the example to what you
actually have on the form?
IE. Me!Text0, Me!TextBox1, Me!TextBoxBob, Me![Actual Textbox Name]
 
L

Lior Montia

give a little bit credit

storrboy said:
It doesn't work.
maybe because the text box got focus by pressing in with the mouse and
not
by pressing TAB in the keyboard ?


Shouldn't matter.
Did you change the names of the controls in the example to what you
actually have on the form?
IE. Me!Text0, Me!TextBox1, Me!TextBoxBob, Me![Actual Textbox Name]
 
S

storrboy

Then I don't know. It works for me.
Are you getting an error? Nothing happens at all?
 
L

Lior Montia

it looks like it goes to the start of the field but then return to the
location I pressed with the mouse.
 
S

storrboy

I understand what you mean now. It's because the Click event occurs
after the GotFocus event.
You'd have to perform the same operation in the click event. If this
was something you're doing to a lot of controls, make a common
function that accepts a control name reference as an argument. Each
control you want this occur in would call the common function passing
it's name and the function would act upon the referenced control.
 
Top