Link to home
Start Free TrialLog in
Avatar of ARampton
ARamptonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

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

Me.YourCombo.SelStart = 0
Me.YourCombo.SelLength = Len(Me.YourCombo)
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.
Avatar of ARampton

ASKER

Tried that but it does not work in Access 2010 forms with a Combo Box
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.
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
Then I think you're stuck ...
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".
I still need a smart way of enabling typing in  ComboBox without double clicking

Has anyone else managed this?
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.
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