Combobox: On enter select entire value

  • Thread starter Thread starter Rasmus
  • Start date Start date
R

Rasmus

Does someone know the VBA line to - on enter (not by TAB) - select the
entire content of a combobox.

If I use TAB to enter the combobox it'll automatically select the entire
content, but if I CLICK into the combobox with the mouse, I have to
mark/select the value myself which is annoying.

I'm looking for a simple OnEnter VBA line to select the content when entered
using the mouse.

Hope you can help :)

Rasmus
 
No need for VBA, and in my mind it will cause user confusion between
standard combo behaviour. Just double click the combo and all text will be
selected.

HTH
Sam
 
Sam D said:
No need for VBA, and in my mind it will cause user confusion between
standard combo behaviour. Just double click the combo and all text will be
selected.

HTH
Sam

Thanks for your heklp, but double-clicking only selects the entire word and
not the entire value.

So there's no way on doing an OnEnter code that automatically selects
everything ?

Rasmus
 
True, sorry didn't realise you had spaces displayed.

You could cause double clicking to select all the text using something
like...

Private Sub Combo0_DblClick(Cancel As Integer)
Me.Combo0.SelStart = 0
Me.Combo0.SelLength = Len(Me.Combo0.Column(1))
Cancel = True
End Sub

Obviously Combo0 needs to be replaced with your combo's name and also the
column selected may need altering. You need to cancel the double click event
to stop it just selecting the current word after you've selected all the
text.

HTH
Sam
 
Back
Top