Solved

Insert cursor into a Combo Box (Not just SetFocus)

Posted on 2010-11-12
7
511 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
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
Back Up Your Microsoft Windows Server®

Back up 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.

 

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

Suggested Solutions

Title # Comments Views Activity
Access database located in "cloud" storage 12 89
File.Search issue 8 30
Error can't find table ?? 5 24
Access/Visual Basic Question 3 24
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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