Hi, i have a form with several controls, which their KeyDown and KeyPress events are:
Private Sub AprovechCombo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then
If IsNull(Me.AprovechCombo.Text) = False And Trim(Me.AprovechCombo.Text) <> "" And enterNotInList = False Then
frutoCombo.visible = True
DoCmd.GoToControl "frutoCombo"
AprovechCombo.visible = False
Else
KeyCode = 0
End If
End If
Private Sub AprovechCombo_KeyPress(KeyAscii As Integer)
If enterNotInList = False Then
If KeyAscii = 13 Or KeyAscii = 9 Then
If IsNull(Me.AprovechCombo.Text) = False And Trim(Me.AprovechCombo.Text) <> "" And enterNotInList = False Then
frutoCombo.visible = True
DoCmd.GoToControl "frutoCombo"
AprovechCombo.visible = False
Else
KeyAscii = 0
End If
End If
The control AprovechCombo is a combobox with its property Limit to list set to Yes. Its NotInList event is:
Private Sub AprovechCombo_NotInList(NewData As String, Response As Integer)
MsgBox "El campo 'Aprovechamiento' debe ser un elemento de la lista. La lista de aprovechamientos puede editarse desde el formulario Ayuda.", 64, ""
Me.AprovechCombo.Dropdown
Response = acDataErrContinue
enterNotInList = True
End Sub
I use the enterNotInList boolean for avoiding that if the introduced text isn't in list the focus goes to the next control. But when the introduced text isn't in list and the tab key is pressed, the code gives the error 2110 : the application can't move the focus to the control frutoCombo. Though the enterNotInList value is True when the KeyDown event enters (it enters after NotInList event), the code runs what is into the if statement
If IsNull(Me.AprovechCombo.Text) = False And Trim(Me.AprovechCombo.Text) <> "" And enterNotInList = False Then
Any solution for going around that?
Thanks for looking.
Private Sub AprovechCombo_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 9 Then
If IsNull(Me.AprovechCombo.Text) = False And Trim(Me.AprovechCombo.Text) <> "" And enterNotInList = False Then
frutoCombo.visible = True
DoCmd.GoToControl "frutoCombo"
AprovechCombo.visible = False
Else
KeyCode = 0
End If
End If
Private Sub AprovechCombo_KeyPress(KeyAscii As Integer)
If enterNotInList = False Then
If KeyAscii = 13 Or KeyAscii = 9 Then
If IsNull(Me.AprovechCombo.Text) = False And Trim(Me.AprovechCombo.Text) <> "" And enterNotInList = False Then
frutoCombo.visible = True
DoCmd.GoToControl "frutoCombo"
AprovechCombo.visible = False
Else
KeyAscii = 0
End If
End If
The control AprovechCombo is a combobox with its property Limit to list set to Yes. Its NotInList event is:
Private Sub AprovechCombo_NotInList(NewData As String, Response As Integer)
MsgBox "El campo 'Aprovechamiento' debe ser un elemento de la lista. La lista de aprovechamientos puede editarse desde el formulario Ayuda.", 64, ""
Me.AprovechCombo.Dropdown
Response = acDataErrContinue
enterNotInList = True
End Sub
I use the enterNotInList boolean for avoiding that if the introduced text isn't in list the focus goes to the next control. But when the introduced text isn't in list and the tab key is pressed, the code gives the error 2110 : the application can't move the focus to the control frutoCombo. Though the enterNotInList value is True when the KeyDown event enters (it enters after NotInList event), the code runs what is into the if statement
If IsNull(Me.AprovechCombo.Text) = False And Trim(Me.AprovechCombo.Text) <> "" And enterNotInList = False Then
Any solution for going around that?
Thanks for looking.