Using SelStart with a ComboBox

HairyArse

Registered User.
Local time
Today, 23:48
Joined
Mar 31, 2005
Messages
92
I have a combo box formatted with an input mask of:

####\-##\-###\-####;0;

When the user clicks in the combo box, usually the cursor ends up in the middle of the string and they have to backspace or press the Home key to return to the start of the field.

I know that for a text field you can automatically move the cursor to the start by using me.control.SelStart = 0 in the On Got Focus event. However, this doesn't work for a combo box.

I've tried on click, on enter and on got focus.
 
It does work for combobox. I use it.

Private Sub cbxSample_Enter()
If Not IsNull(Me.cbxSample) Then Me.cbxSample.SelStart = Len(Me.cbxSample)
Me.cbxSample.Dropdown
End Sub
 
I've tried the following in the On Enter event and it doesn't work for me. Access 2013.

'Move the cursor to the start of the cbo if empty
If IsNull(Me.cbo_nsn) Or (Me.cbo_nsn = "") Then
Me.cbo_nsn.SelStart = 0
End If

I've even tried adding .Column(1) as my cbo_nsn field has the id hidden but this makes no difference.

If IsNull(Me.cbo_nsn) Or (Me.cbo_nsn = "") Then
Me.cbo_nsn.Column(1).SelStart = 0
End If
 
I've also tried your code and it makes no difference.
 
I suspect it's the input mask over-riding the normal behaviour.

Why do you need it? Shirley a combo is already presenting the data as you need it?
 
Minty beat ne to it. Try removing the input mask at least temporarily.
Also have you checked the default behaviour in the client settings of Access options?
 
You're right. Removing the input mask sorts it.

The input mask is just to stop my users having to type hyphens but I think it's a small price to pay to have the cursor in the correct place.

Thanks guys. :)
 
Actually, removing the input mask doesn't technically sort it. It's just that without the input mask it's impossible for the cursor to be anywhere other than at the start.
 
Not if you change the client settings as I suggested. However that has to be done on each workstation


Sent from my iPhone using Tapatalk
 

Users who are viewing this thread

Back
Top Bottom