Return key using Combo box

Taking into consideration that when using a combo box, the enter key is used when making a selection from your drop down list. Our users would like to use the enter key for leaving the field. As it stands they prefer not to use the tab key, is there any way around this? Another consideration is that i am an advanced/beginner at VB6, so my understanding my be a little slower than most others in the field. Thanks for your help!!!!
jimmy
j777Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sunil27Commented:
You may add the following code in the KeyPress Event of the Combo box:


Private Sub Combo1_KeyPress(KeyAscii As Integer)
    '
    ' If the key pressed is Enter (KeyAscii value 13) then send the Tab key using sendkeys statement.

    If KeyAscii = 13 Then
        SendKeys "{TAB}"
    End If
       
End Sub
0
j777Author Commented:
very simply, it just did not work. if i understand correctly you were rerouting the keyboard but it still did not help when i hit the enter key. Again my hopes are that once you make a selection from the drop down list or manually enter the entry just by clicking the enter key will force the leaving of that field. Thank you for the help though, if you have any other suggestions please foward them to me!!
0
SiM99Commented:
so, you want the enter key to select the highlighted item in the list, and then for the cursor to go to another control, like a textbox ??

if so, why not just use the following code (in the keypress event of the combo box):

If KeyAscii = 13 Then Text1.SetFocus

Hope this helps....

SiM99
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

KhollADCommented:
You can use the trick below :

Private Sub Form_Load()

    Me.KeyPreview = True
   
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = 13 Then
        SendKeys "{Tab}", True
    End If
   
End Sub
0
ChaseZeroCommented:
private_sub combo1_Change()
'On change ie when the enter is pressed and a selection is made

  text1.setfocus

end sub

the above will work if and only if u have set the "Default" to false on any command button, cos if u have a command button with default set to 'true' when enter is pressed that command  button is triggered by default

Hope this helps... as the info u are asking for is not terribly clear

ChaseZero
0
j777Author Commented:
i am sorry if i did not make my situation clear. As it stands using the enter key the way a combo box has intended works properly. The problem is that the user wants,(for a lack of better explanation), to have the enter key have a dual function. The main function would be to use the enter key as if the combo box was not on the form at all, anotherwords just go to the next field, as well as the normal functionality it already has with the combo box.
0
SiM99Commented:
set formname.keypreview = true (in the form properties, not through code)

then, you can use form_keypress and check for keyascii 13 to carry out whatever code you wish.

By the way... what exactly would the form do when the combo box is not there ?
0
j777Author Commented:
I have actually tried this to no avail. It seems that with the combo box on the form the enter key is only recognized for its' use within the combo box limitations. The reason for the combo box is that i am populating it with a sybase list of project numbers. But the user needs to be able to manually enter a project number then hit the enter key to leave the field and do the next retreive.
0
paul_tsekovCommented:
Hi i777,
  I had the same problem.
  I wanted to use the <Enter> key to
 make the focus go to the next control,
but it showed me the drop-down list.

 so, how did I solve it?

 I just use the arrow UP and arrow DOWN
keys for changing the focus.
  I made the Enter change the focus on each control , except the ComboBox.

   So, that it all the controls change the focus by ARROWS and ENTER.
   Only in ComboBox change the focus
only with ARROWS.

  To change the focus with arrows you
should use the Key_Down or the Key_up events.
 
 So here is some code that could be useful to you:

Private Sub Text2_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)

Select Case KeyCode
Case vbKeyDown
     Text1.SetFocus
Case vbKeyUp
     Text3.SetFocus
End Select      

End Sub

  So , remember there is no real solution to your problem.
  You must choose between showing the Drop-Down list or changing the focus.!!!!!!

       Pavel Tsekov
     email : paul_tsekov@yahoo.com


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.