D
Duck
I have a form with among others two combo boxes on of which displays a
list of Vendors and the other displays a list of Models and is
dependant upon the which vendor is chosen in the first combobox. Both
are bound to the Vendor and Model fields in the table tblLinked. The
'Limit to list' property is set to 'yes' for both.
I want the user to be able to add new Vendors, and Models as
necessary, but I want them to be prompted first (when a new item is
typed in the box) My problems is that eventhough I am using basically
the same code in the 'NotInList' event of both boxes, the Model
combobox keeps giving me the error "The text you entered isn't an Item
in the list". The error never occurs with the Vendor box but always
orrcurs is the Model box.....Please Help!!
Here is the code for both boxes (Vendor First)
*******************************************************
Private Sub Vendor_NotInList(NewData As String, Response As Integer)
Dim cnn As New ADODB.Connection
Dim strSQL As String
Dim bytResponse As Byte
Set cnn = CurrentProject.Connection
bytResponse = MsgBox(NewData & " Is a new vendor, Do you want to add
it " _
& "to the list?", vbYesNo + vbQuestion, "New Vendor Detected")
If bytResponse = vbYes Then
strSQL = "INSERT INTO tblLinked(Vendor) VALUES('" _
& NewData & "')"
'Debug.Print strSQL
cnn.Execute strSQL
Response = acDataErrAdded
ElseIf bytResponse = vbNo Then
Response = acDataErrContinue
Me!Vendor.Undo
End If
End Sub
************************************************************
*******************************************************
Private Sub Model_NotInList(NewData As String, Response As Integer)
Dim cnn As New ADODB.Connection
Dim strSQL As String
Dim bytResponse As Byte
Set cnn = CurrentProject.Connection
bytResponse = MsgBox(NewData & " Is a new model..Do you want to add
it " _
& "to the list?", vbYesNo + vbQuestion, "New Item Detected")
If bytResponse = vbYes Then
strSQL = "INSERT INTO tblLinked(Model) VALUES('" _
& NewData & "')"
Debug.Print strSQL
cnn.Execute strSQL
Response = acDataErrAdded
ElseIf bytResponse = vbNo Then
Response = acDataErrContinue
Me!Model.Undo
End If
End Sub
******************************************************
list of Vendors and the other displays a list of Models and is
dependant upon the which vendor is chosen in the first combobox. Both
are bound to the Vendor and Model fields in the table tblLinked. The
'Limit to list' property is set to 'yes' for both.
I want the user to be able to add new Vendors, and Models as
necessary, but I want them to be prompted first (when a new item is
typed in the box) My problems is that eventhough I am using basically
the same code in the 'NotInList' event of both boxes, the Model
combobox keeps giving me the error "The text you entered isn't an Item
in the list". The error never occurs with the Vendor box but always
orrcurs is the Model box.....Please Help!!
Here is the code for both boxes (Vendor First)
*******************************************************
Private Sub Vendor_NotInList(NewData As String, Response As Integer)
Dim cnn As New ADODB.Connection
Dim strSQL As String
Dim bytResponse As Byte
Set cnn = CurrentProject.Connection
bytResponse = MsgBox(NewData & " Is a new vendor, Do you want to add
it " _
& "to the list?", vbYesNo + vbQuestion, "New Vendor Detected")
If bytResponse = vbYes Then
strSQL = "INSERT INTO tblLinked(Vendor) VALUES('" _
& NewData & "')"
'Debug.Print strSQL
cnn.Execute strSQL
Response = acDataErrAdded
ElseIf bytResponse = vbNo Then
Response = acDataErrContinue
Me!Vendor.Undo
End If
End Sub
************************************************************
*******************************************************
Private Sub Model_NotInList(NewData As String, Response As Integer)
Dim cnn As New ADODB.Connection
Dim strSQL As String
Dim bytResponse As Byte
Set cnn = CurrentProject.Connection
bytResponse = MsgBox(NewData & " Is a new model..Do you want to add
it " _
& "to the list?", vbYesNo + vbQuestion, "New Item Detected")
If bytResponse = vbYes Then
strSQL = "INSERT INTO tblLinked(Model) VALUES('" _
& NewData & "')"
Debug.Print strSQL
cnn.Execute strSQL
Response = acDataErrAdded
ElseIf bytResponse = vbNo Then
Response = acDataErrContinue
Me!Model.Undo
End If
End Sub
******************************************************