L
lmv
I have a combobox that triggers the next box to only list suppliercode with
that ProdID. The supplierCode field then has the number SOMETIMES the ProdID
can have a different number if it comes from a different supplier I want to
use my NotInList event to add the info. I know how to add just the supplier
code but what is the syntax to add the prodID as well? (this tblsupplierCode
has an auto number set as PK)
Thanks!
Private Sub cboSupplierCode_NotInList(NewData As String, Response As Integer)
On Error GoTo SupplierCode_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The Supplier Code " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Purchase Order Subform")
If intAnswer = vbYes Then
strSQL = "INSERT INTO tblSupplierCodes([SupplierCode]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
'CurrentDb.Execute strSQL, dbFailOnError
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new Supplier Code has been added to the list."
Response = acDataErrAdded
Else
MsgBox "Please choose a Supplier Code from the list." & vbCrLf & _
"Use the ESC to return value to the box."
Response = acDataErrContinue
End If
SupplierCode_NotInList_Exit:
Exit Sub
SupplierCode_NotInList_Err:
MsgBox err.Description, vbCritical, "Error"
Resume SupplierCode_NotInList_Exit
End Sub
that ProdID. The supplierCode field then has the number SOMETIMES the ProdID
can have a different number if it comes from a different supplier I want to
use my NotInList event to add the info. I know how to add just the supplier
code but what is the syntax to add the prodID as well? (this tblsupplierCode
has an auto number set as PK)
Thanks!
Private Sub cboSupplierCode_NotInList(NewData As String, Response As Integer)
On Error GoTo SupplierCode_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The Supplier Code " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Purchase Order Subform")
If intAnswer = vbYes Then
strSQL = "INSERT INTO tblSupplierCodes([SupplierCode]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
'CurrentDb.Execute strSQL, dbFailOnError
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new Supplier Code has been added to the list."
Response = acDataErrAdded
Else
MsgBox "Please choose a Supplier Code from the list." & vbCrLf & _
"Use the ESC to return value to the box."
Response = acDataErrContinue
End If
SupplierCode_NotInList_Exit:
Exit Sub
SupplierCode_NotInList_Err:
MsgBox err.Description, vbCritical, "Error"
Resume SupplierCode_NotInList_Exit
End Sub