Combobox: On enter select entire value

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
 
S

Sam D

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
 
R

Rasmus

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
 
S

Sam D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top