F
fiaolle
I have a form with a combobox and I want the users to be able to use the
Arrow buttons to change the value in the combobox. And when the users press
Enter the focus moves to the OK-button. The OK button's property Tabbstop is
set to False.
But when the users type something that's not in the combobox and presses
Enter I get the error 2110. When I debug it runs the code cmdOK.Setfocus and
there after runs the event cmbDatum_NotInList , but after the NotInList
event is finsish it goes back to the code cmdOK.Setfocus and says the error
2110.
I don't know what to do
Pleeease Help
Private Sub cmbDatum_KeyDown(KeyCode As Integer, Shift As Integer)
cmbDatum.SetFocus
Select Case KeyCode
Case 40 'Piltangent ner
If cmbDatum.ListIndex + 1 < cmbDatum.ListCount Then
cmbDatum.ListIndex = cmbDatum.ListIndex + 1
End If
Case 38 'Piltangent upp
If cmbDatum.ListIndex - 1 + 1 > 0 Then
cmbDatum.ListIndex = cmbDatum.ListIndex - 1
End If
Case 13 'Enter knapp
cmdOK.SetFocus
End Select
End Sub
Private Sub cmbDatum_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue ' I have tried both acDataErrAdded
MsgBox "Skriv in ett datum som finns ", vbOKOnly, "Varning"
Me.cmbDatum.SetFocus
Me.cmbDatum.ListIndex = 0
Me.cmbDatum.SelStart = 0
Me.cmbDatum.SelLength = Len(Me.cmbDatum.Text)
End Sub
Arrow buttons to change the value in the combobox. And when the users press
Enter the focus moves to the OK-button. The OK button's property Tabbstop is
set to False.
But when the users type something that's not in the combobox and presses
Enter I get the error 2110. When I debug it runs the code cmdOK.Setfocus and
there after runs the event cmbDatum_NotInList , but after the NotInList
event is finsish it goes back to the code cmdOK.Setfocus and says the error
2110.
I don't know what to do
Pleeease Help
Private Sub cmbDatum_KeyDown(KeyCode As Integer, Shift As Integer)
cmbDatum.SetFocus
Select Case KeyCode
Case 40 'Piltangent ner
If cmbDatum.ListIndex + 1 < cmbDatum.ListCount Then
cmbDatum.ListIndex = cmbDatum.ListIndex + 1
End If
Case 38 'Piltangent upp
If cmbDatum.ListIndex - 1 + 1 > 0 Then
cmbDatum.ListIndex = cmbDatum.ListIndex - 1
End If
Case 13 'Enter knapp
cmdOK.SetFocus
End Select
End Sub
Private Sub cmbDatum_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue ' I have tried both acDataErrAdded
MsgBox "Skriv in ett datum som finns ", vbOKOnly, "Varning"
Me.cmbDatum.SetFocus
Me.cmbDatum.ListIndex = 0
Me.cmbDatum.SelStart = 0
Me.cmbDatum.SelLength = Len(Me.cmbDatum.Text)
End Sub