Set the cursor position

B

Bob Howard

I have a field with an input mask. When the user wants to type in that
field, they sometimes simply click in the field and start typing.

But I want them to always start entering data at the first position of the
field (which is usually not where they click).

What sort of VBA code would I use to move the "cursor" to the first position
of the field (I assume this would be in a GotFocus event ... or something
like that)??

thanks. bob.
 
F

fredg

I have a field with an input mask. When the user wants to type in that
field, they sometimes simply click in the field and start typing.

But I want them to always start entering data at the first position of the
field (which is usually not where they click).

What sort of VBA code would I use to move the "cursor" to the first position
of the field (I assume this would be in a GotFocus event ... or something
like that)??

thanks. bob.

If the user clicks into the field, the cursor position will be where
ever the user has clicked.

If the user tab's into the field, you can position the cursor at the
beginning.
Code the control's Enter event:

Me.[ControlName].SelStart = 1

Or ...

to position it at the end of the existing data, you can use:

Me.[ControlName].SelStart = Len(Me.[ControlName])
 
D

Dirk Goldgar

fredg said:
If the user clicks into the field, the cursor position will be where
ever the user has clicked.


There's a workaround for this, but it may be more trouble than it's worth.
You can cover the text box with a transparent command button, making sure
that (a) the command button is in front of the text box, and (b) the command
button's Tab Stop property is set to No//False. Then you can the command
button's Click event procedure to set the focus to the text box.
 
L

Linq Adams via AccessMonster.com

OnEnter only works if the textbox is tabbed into, not if it's clicked in.

Private Sub YourTextBox_Click()
Me.YourTextBox.SelStart = 0
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 

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

Similar Threads


Top