This code inserts the cboCustomerID value into the CustomerID field in the table named tblProofTypesLU. But I want to give the user the ability to add the current Customer ID as it does now BUT allow them to not use the current Customer ID but rather, insert a 0 (zero) if they indicate they don't want to insert the current Customer ID.
Private Sub cboProofType_NotInList(NewData As String, Response As Integer) On Error GoTo Err_cboProofType_NotInList Dim intAnswer As Integer Dim strSQL As String intAnswer = MsgBox(NewData & " is not in the list. Would you like to add it?", vbQuestion + vbYesNo, "Description") If intAnswer = vbYes Then strSQL = "INSERT INTO tblProofTypesLU([Description],[CustomerID]) " & "VALUES ('" & NewData & "'," & Forms!frmEstimates.cboCustomerID & ");" CurrentDb.Execute strSQL, dbSeeChanges Response = acDataErrAdded End If Exit_cboProofType_NotInList: Exit Sub Err_cboProofType_NotInList: MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source Resume Exit_cboProofType_NotInList End Sub
From novice to tech pro — start learning today.