I have ComboBox in Access form. It show list of items from db table. If item isn't found I want to create this record. So I use NotInList event:
Private Sub Combo9_NotInList(NewData As String, Response As Integer)
DoCmd.GoToRecord , , acNewRec
End Sub
When I'm trying to enter not existing item in ComboBox, it gives error:
But I created button and added the same code onClick event and it's working without problem.
What is wrong with NotInList? How I can use this event to add new record?
You need to clear the error and whatever is entered.
Private Sub cboSelect_NotInList(NewData As String, Response As Integer)
Response = acDataErrContinue
MsgBox "New entries are not permitted." & vbCrLf & vbCrLf & _
"Please select an entry from the list or " & vbCrLf & _
"move to a new record and add a new item below. ", , _
"MsgBox Title"
Me.cboSelect.Undo
End Sub