Hello all,
I am creating an application that has an equipment inventory and maintenance form that has numerous subforms that are displayed depending on the category of equipment selected.
I have two common combo boxes on each subform - "Supplier" and "Manufactur er". I use the following code for the "NotInList" event and it works fine. (This is the version for the "Supplier" cbo)
[I]
I would like to include these once as a public function or sub and call them with the NotInList event of each combo box but have had no success in getting this to work. The row source tables are the same for these cbo boxes on all 18 subforms.
I am creating an application that has an equipment inventory and maintenance form that has numerous subforms that are displayed depending on the category of equipment selected.
I have two common combo boxes on each subform - "Supplier" and "Manufactur er". I use the following code for the "NotInList" event and it works fine. (This is the version for the "Supplier" cbo)
[I]
Code:
[I]Public Sub cboSupplier_NotInList(NewData As String, Response As Integer)
On Error GoTo cboSupplier_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The Supplier " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "I-TEAM Utilities")
If intAnswer = vbYes Then
strSQL = "INSERT INTO tbl_Suppliers([SupName]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new Supplier has been added to the list." & _
" Please enter remaining contact information" & vbCrLf & _
"before proceeding further" _
, vbInformation, "I-TEAM Utilities"
Response = acDataErrAdded
DoCmd.OpenForm "frm_Test2"
Else
MsgBox "Please choose a Supplier from the list." _
, vbInformation, "I-TEAM Utilities"
Response = acDataErrContinue
End If
cboSupplier_NotInList_Exit:
Exit Sub
cboSupplier_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboSupplier_NotInList_Exit
End Sub
Comment