mark data in a text box

StefanSch

Registered User.
Local time
Today, 17:08
Joined
Jan 18, 2003
Messages
136
Hello,

I have a form with a few text boxes (user should enter numbers).

When the users click on the text boxes I would like Access to mark the data in the relevant text box. By this, users may change the data in text boxes more easier.

Do you have any ideas?

Stefan
 
Ahh, yes, the old setting the cursor with the Mouse problem.

You can set the selection behavior of the keyboard under the Tools/Options menu if that was all you needed. But if you want to force the Mouse to behave the same way, I think you could put the following in the OnEnter event of your textbox controls:

*******************************
With Me!NameOfTextBox
.SelStart = 0
.SelLength = Len(Me!NameOfTextBox)
End With
*******************************

HTH,
John
 
Thanks a lot jjturner

Unfortunately the code did not work in the on enter event (error 13).

Is there something wrong in the code?

regards, Stefan
 
My bad . . .

Move it to the OnGotFocus event (and change 'NameOfTextBox' to the actual name of your text box).
 
Unfortuantely, it is still not marking the data in the text field.

Thank you for your help. I appreciate it.

regards,

Stefan
 
This seems to be a bigger can of worms than I originally thought :p

I'll keep trying to fish around for a satisfactory solution. In the meantime, have a read through this post.

As you'll see, controlling the cursor behavior from a mouse click on change of focus to a textbox is not so trivial. I think there's another post dealing with this topic . . . will keep searching.

Regards,
John
 
GOT IT!

Stefan,

Use the On Click event for your text boxes. Go to the ellipsis button ('...') and click Code Builder. This brings you to the code module.

Paste the following line in your event procedure:

SendKeys "{F2}"

Note: this will disable your mouse from being able to position the cursor within the textbox. There's a complicated workaround to re-enable the positioning once the control receives focus, but for now see if this will suffice.

HTH,
John
 
Perfect, JJTurner

Thank you very much.

regards, Stefan
 

Users who are viewing this thread

Back
Top Bottom