We help IT Professionals succeed at work.

Access Combo Box AutoSelect content on Click

I want to automate what is achieved by double clicking in a combo box ProjectNumberFind with VB code so the visible content is selected and will then get replaced by what a user next types

I find selecting the contents of Text Boxes speeds data entry by using OnClick but can't make it work with my Combo Box
Me.Form.ProjectNumberFind.SelStart = 0
Me.Form.ProjectNumberFind.SelLength = Len(Me.Form.ProjectNumberFind.Text)

Me.ProjectNumberFind.SetFocus achieves what I want when triggered from another location but I can't find any way of making the cursor auto select my Combo Box without double clicking
Comment
Watch Question

Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
You can do something like this in the Enter or GotFocus event:

Me.YourCombo.SelStart = 0
Me.YourCombo.SelLength = Len(Me.YourCombo)
Distinguished Expert 2017

Commented:
If you teach people to tab through the controls rather than clicking, you won't need any code at all.  each will be selected automatically.
ARamptonIT Manager

Author

Commented:
Tried that but it does not work in Access 2010 forms with a Combo Box
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
Try it in the MouseUp event. You may also need to refer to the Column of the Combo:

Me.YourCombo.SelLenght = Len(Me.YourCombo.Column(1))

Assuming the second column in your combo contains the text shown in the combo.
ARamptonIT Manager

Author

Commented:
I can't get Me.YourCombo.SelLenght = Len(Me.YourCombo.Column(1)) to work

Tried using Me.YourCombo.SelStart = 0 &  Me.YourCombo.SelLength = Len(Me.YourCombo) with OnMouseUp which does work but MouseUp is needed for normal operation of selecting an entry from the dropdown list so causes conflict when used
Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
Then I think you're stuck ...
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
ARamptonIT Manager

Author

Commented:
I still need a smart way of enabling typing in  ComboBox without double clicking

Has anyone else managed this?
You need some additional logic in MouseUp. Selection should be made only once after got focus. Look at sample
DB28654977.accdb
ARamptonIT Manager

Author

Commented:
Thanks

Your example seems to do just what I want, I was thinking it might need some form of counter to disable subsequent selection when one needs to use the combobox dropdown menu

I will try your process in my Database
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
I've requested that this question be closed as follows:

Accepted answer: 500 points for als315's comment #a40768289

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ARamptonIT Manager

Author

Commented:
Excellent solution

I was thinking of trying something similar myself but great to have someone who already knows a workable solution

I find it frustrating so many other experts think there is no way of achieving what you have proved works nicely