Moving focus after Enter is pressed
Moving focus after Enter is pressed
(OP)
I have a Combo Box and am using AddItem after the text is replaced/edited. After Enter is pressed I want the focus to then move to the Text Box below, so this entry can also be edited/replaced.
It has defeated me! Please experts help me.
Tony
It has defeated me! Please experts help me.
Tony





RE: Moving focus after Enter is pressed
CODE
Select Case KeyAscii
Case Asc(vbCr)
KeyAscii = 0
SendKeys vbTab
End Select
End Sub
RE: Moving focus after Enter is pressed
I tried your suggestion and having reordered the tabs it worked very well.
Thankyou again Tony
RE: Moving focus after Enter is pressed
RE: Moving focus after Enter is pressed
You could also try the following using the setfocus method (it isn't tab order dependent).
A simple form with a textbox and combo box in VB6...
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "Fred"
Combo1.AddItem "Bill"
Combo1.AddItem "Dave"
End Sub
RE: Moving focus after Enter is pressed
In some cases, that can lead to confusion on the part of the users, not understanding why the program behaves differently.
RE: Moving focus after Enter is pressed