SelStart and SelLength

MikeAngelastro

Registered User.
Local time
Today, 07:28
Joined
Mar 3, 2000
Messages
254
Hi,

I have tried everything but I have yet to get these two properties to work. All I want is to have the entire contents of the text box highlighted after the text box receives the focus. I am using Access 2002 and I also have the options set to select entire field upon entry.

I have tried every technique suggested in this forum but, when the code runs, the cursor just sits there at the beginning of the field.

The data in field is numeric which tends to have right-to-left logic as opposed to the left-to-right logic of alpha characters. Could this make a difference?

Any help on what should be a simple operation.

Thanks,

Mike
 
Mike,

Put this code in a standard module:
Code:
Public Function SelectAll()
  On Error Resume Next
  
  Dim ctl As Control
 
  Set ctl = Screen.ActiveControl
  ctl.Selstart = 0
  ctl.SelLength = Nz(Len(ctl.value),0)
End Function
In the 'On GotFocus' property of the textbox:
=SelectAll()
 
Thanks Bert.

I followed your instructions and I got the same result. None of the contents of the text box was highlighted. Could there be a configuration issue? If it works for you, it should work for me.

Thanks again,

Mike
 
Mike,

I have A2000 and I set things up as you did, numeric field
and enter-field behavior. Mine selects all of the field.

I wouldn't have expected it, but it does. Must be a new
"feature" of A2002.

Wayne
 
Thanks Wayne,

With MS, bugs not owned up to are features.

Take care. I guess I'll have to live with it.

Mike
 
Ok, I didn't see directly that is was in a numeric field. Than it gives more problems, because of the Notation (ie #,##0.00), so sometimes a part of the field is selected...
I use it in Access 2002.

Can you attach a copy/extraction of the db with the problem, then I'll have a look at it
 

Users who are viewing this thread

Back
Top Bottom