I have 4 comboboxes each filtered by the previous. When entering a new record, it asks if I want to add the record....answer yes, and the record is added. However, if I add a record in the first combobox and proceed to the next and add a new record to the next combobox, they are not related properly. What code do I need to add to get this to function properly?
Here is the current code for the 2nd combobox:
' If Entered Product is not in List allow add.
Private Sub cboProduct_NotInList(NewData As String, Response As Integer)
'Supress the default error message.
Response = acDataErrContinue
'Ask user if they want to add the new Product to the list/database
If MsgBox(NewData & " is not in list of Products. Add it?", vbYesNo) = vbYes Then
Dim db As Database
Dim rstProducts As Recordset
Dim sqlProducts As String
Set db = CurrentDb()
sqlProducts = "Select * From Products"
'Create a new recordset to add the new PRODUCT to the database.
Set rstProducts = db.OpenRecordset(sqlProducts, dbOpenDynaset)
rstProducts.AddNew
rstProducts![Product] = NewData
rstProducts![ManufacturerID] = cboMfg.Value
rstProducts.Update
'Inform the combobox that the desired item has been added to the list.
Response = acDataErrAdded
rstProducts.Close 'Close the recordest
End If
End Sub
Please help,
Thanks