Solved

Insert cursor into a Combo Box (Not just SetFocus)

Posted on 2010-11-12
7
506 Views
Last Modified: 2013-11-28
I have situation where i need to do a bit more than just Set Focus and Dropdown a Combo Box.  I need to go just one step further and actually have the cursor set into the Combo Box standing ready to receive keystrokes.

Background: I am using a gaming keypad with programmable keys/buttons to speed data entry. Right now, the SetFocus and Dropdown part works fine but I still have to click my mouse inside the Combo Box before I can press one of the programmed keys and I would like to eliminate that step.

Thanks in adavnce for any advice.
0
Comment
Question by:dgheck
7 Comments
 
LVL 7

Accepted Solution

by:
rogerard earned 50 total points
Comment Utility
This should work.
Me.Combo0.SetFocus
    Me.Combo0.SelStart = 0
    Me.Combo0.SelLength = 0

Open in new window

0
 
LVL 30

Expert Comment

by:hnasr
Comment Utility
SetFocus to combo makes it ready to accept input.
It selects what inside the box.

Me.Combo.SelStart = 0
Unselects the text and moves the cursor to the beggining of the text in the comboBox.
0
 
LVL 7

Expert Comment

by:rogerard
Comment Utility
Technically, true

You can modify as you need see below:
me.combo0.SetFocus 'Sets focus on control and selects all of the existing value'

me.Combo0.selStart = Len(Combo0.SelText) 'sets the cursor to the last position of any text'

Me.Combo0.SelStart = 0 'sets the cursor to the first position of any text'

Open in new window

0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:dgheck
Comment Utility
Have tried the code above (and several variations and orders) and still can't get it position the cursor into the Combo Box. I still have to manually click inside the Combo bax before I can fire the programmed keys.

A possible complication: Contained in the form is a WebBrowserDocWindow control that seems to want to steal the focus. And I am not even sure what I mean by that.  I have set the WebBrowserDocWindow_DocumentComplete event to set the focus to the Combo Box but I am not convinced that the WebBrowserDocWindow totally lets go.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
I too have a programmable keypad.

I will say from experience that:
1. The code the experts above posted should work under normal circumstances.
2. The way these keypads send the keystrokes to the application may be part of the issue here. depending o the type of software it uses sending keystroke to the application will not be the same as, say, using SendKeys.

"Contained in the form is a WebBrowserDocWindow control that seems to want to steal the focus."
Then can you delete it and test the posted solutions?
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now