Solved Position the cursor at the end of the textbox

zelarra821

Registered User.
Local time
Today, 14:50
Joined
Jan 14, 2019
Messages
850
Good afternoon.

I'm trying to get my cursor at the end in a textbox after updating it, but I can't. I have recorded a short video that supports my words and you can see the behavior.

Video

This is the code I have after updating:

Code:
Private Sub Leido1_AfterUpdate()
'    If IsNull(Me.Leido1) Then
'        Me.Leido1 = 0
'    End If
    DoCmd.Requery
'    CargarValores Me
End Sub

The problem is in the DoCmd.Requery, which I use to update the form and the calculated values that you see throughout the form. The rest of the code that you see commented does not affect the problem, that's why I have it like this.

If I put a breakpoint in VBA it just goes through that DoCmd.Requery, for nothing else.

If I try to force it, for example, like this:

Code:
Me.Leido1.SelStart = Len(Me.Leido1) + 1

continues to be at the beginning.

How can i fix it?

Thanks.
 
Your control is numeric and likely right justified, so the selstart will be to the left not right.?
If it was a string, then you would get the cursor to the right?
 
The control is indeed numeric, but it is centered, not right-aligned. Here you can see it more clearly:

ScreenShot001.jpg


In addition, you are right that if it were a string, place the cursor to the right, even being centered, as you can see in the image.

So how do you fix this?
 
By the way, the alignment that I give to the field in the table is general.
 
Hi. Just curious, what do you get if you use SelStart=0?
 
I just tried it on a numeric control and the selstart is to the left.?
 
So it is doing exactly what I said it would do?
I do not see the SelStart = 0 being used.?
 
So it is doing exactly what I said it would do?
That's right, if it is numeric, it places it on the left, as you say.
I do not see the SelStart = 0 being used.?
Take a good look at the video because I do use it.

I have made another change in menu> File / Options / Client configuration / Behavior when entering the field -> "Go to the end of the field", but it does not solve it either.
 
I have already found the solution.

I have to change the reading order in the properties of the text box from "Context", to "Right to Left".

Thanks a lot!
 
I have already found the solution.

I have to change the reading order in the properties of the text box from "Context", to "Right to Left".

Thanks a lot!
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom