Solved

Insert cursor into a Combo Box (Not just SetFocus)

Posted on 2010-11-12
7
514 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Accepted Solution

by:
rogerard earned 50 total points
ID: 34120546
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
ID: 34123876
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
ID: 34123959
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dgheck
ID: 34124018
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
ID: 34124913
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
ID: 34840125
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

734 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