selection of text in a combo box

G

george

I would like to be able to select the whole text when I
click in the text area of a combo box (instead of placing
the cursor in the text area) so that I can start typing
right away and not having to erase what's already there.
How do I do this? Thanks in advance, george.
 
J

John Vinson

I would like to be able to select the whole text when I
click in the text area of a combo box (instead of placing
the cursor in the text area) so that I can start typing
right away and not having to erase what's already there.
How do I do this? Thanks in advance, george.

If you Tab into the combo box rather than clicking, it will do so by
default and you won't need to move your hand from the keyboard.

If you do want to use the mouse you'll need some VBA code in the
combo's GotFocus event: something like

Me.comboboxname.SelStart = 1
Me.comboboxname.SelLen = Len(Me!comboboxname.Text)
 
T

TC

Try putting this in the Enter or GotFocus event of the combo:

(untested)

with screen.activecontrol
.selstart = 0
.sellength = 32000
end with

HTH,
TC
 
J

John Vinson

I appreciate your help but unfortunately it didn't work.

Sorry... my typo: should be

Me.comboboxname.SelStart = 1
Me.comboboxname.SelLength = Len(Me!comboboxname.Text)

using your own combo box's name in place of comboboxname. If this
doesn't work please post your actual code, and the name of the combo
box.
 
G

george

this doesn't work either. I get a message: "RunTime error
438 Object doesn't support this property or method"

thanks, george
 
G

george

Unfortunately this doesn't work either. The name of my
combo box is generic: "combo77" and the code is exactly
what you proposed. On the OnGotFocus Event of in the
properties sheet of my combo77 I entered this code:

Me.combo77.SelStart = 1
Me.combo77.SelLength = Len(Me!combo77.Text)

Trying to find an answer I noticed that when I click on
the Label next to my combo box with the caption "Search"
then the whole text in the combo is selected. This is
something but still I would prefer to click inside the
combo box.

Thanks again John.
 

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