Hi All,
I have a form with a combo box which contains a list of users, also the form contains 2 buttons "Exit" & "Begin".
When I click arrow key "up" focus moves to Exit and the code is executed (this also happens when I press shift tab). The same happens when I press arrow key "down" only focus moves to Begin.
Issue 1
I cannot stop focus moving from the combo box (code in the combo box code below). How do I keep focus on this combo box?
Private Sub User_combo_KeyDown(KeyCode As Integer, Shift As Integer)
User_combo.SetFocus 'set focus is not working!!!!
Select Case KeyCode
Case vbKeyDown
If ser_combo.ListIndex <> ser_combo.ListCount - 1 Then
ser_combo.ListIndex = ser_combo.ListIndex + 1
Else
ser_combo.ListIndex = 0
End If
Case vbKeyUp
If ser_combo.ListIndex <> 0 Then
ser_combo.ListIndex = ser_combo.ListIndex - 1
Else
ser_combo.ListIndex = ser_combo.ListCount - 1
End If
End Select
End Sub
Issue 2
When I tab between the objects on the form the code is being executed the moment focus is placed. How do I prevent this and just cause the focus to move and not have the code executed?
/Nice
I have a form with a combo box which contains a list of users, also the form contains 2 buttons "Exit" & "Begin".
When I click arrow key "up" focus moves to Exit and the code is executed (this also happens when I press shift tab). The same happens when I press arrow key "down" only focus moves to Begin.
Issue 1
I cannot stop focus moving from the combo box (code in the combo box code below). How do I keep focus on this combo box?
Private Sub User_combo_KeyDown(KeyCode As Integer, Shift As Integer)
User_combo.SetFocus 'set focus is not working!!!!
Select Case KeyCode
Case vbKeyDown
If ser_combo.ListIndex <> ser_combo.ListCount - 1 Then
ser_combo.ListIndex = ser_combo.ListIndex + 1
Else
ser_combo.ListIndex = 0
End If
Case vbKeyUp
If ser_combo.ListIndex <> 0 Then
ser_combo.ListIndex = ser_combo.ListIndex - 1
Else
ser_combo.ListIndex = ser_combo.ListCount - 1
End If
End Select
End Sub
Issue 2
When I tab between the objects on the form the code is being executed the moment focus is placed. How do I prevent this and just cause the focus to move and not have the code executed?
/Nice