Solved

Insert cursor into a Combo Box (Not just SetFocus)

Posted on 2010-11-12
7
508 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
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.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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 …

863 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

26 Experts available now in Live!

Get 1:1 Help Now