Hello,
I am trying to set up a combo box that will allow new data as well. I found some code* to do this, but it isn't working. The combo box will populate a field in a relationship. Also this is part of a subform.
Runtime error '3192'
Cannot find output table 'tblParts'
How do I use the NotInList event?
I can explain my entire situation and upload my database if it will help.
Thanks In Advance
*
Private Sub ComboPartID_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "'is a new part!." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Part Number...")
If i = vbYes Then
strSQL = "Insert Into tblParts ([strParts]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
I am trying to set up a combo box that will allow new data as well. I found some code* to do this, but it isn't working. The combo box will populate a field in a relationship. Also this is part of a subform.
Runtime error '3192'
Cannot find output table 'tblParts'
How do I use the NotInList event?
I can explain my entire situation and upload my database if it will help.
Thanks In Advance

*
Private Sub ComboPartID_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "'is a new part!." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Part Number...")
If i = vbYes Then
strSQL = "Insert Into tblParts ([strParts]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
Last edited: