Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Insert cursor into a Combo Box (Not just SetFocus)

Posted on 2010-11-12
7
Medium Priority
?
518 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
6 Comments
 
LVL 7

Accepted Solution

by:
rogerard earned 200 total points
ID: 34120546
This should work.
Me.Combo0.SetFocus
    Me.Combo0.SelStart = 0
    Me.Combo0.SelLength = 0

Open in new window

0
 
LVL 31

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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

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 93

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 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…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

876 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