G
Guest
I have created a form that uses data from the Vendors tbl (Vendor Name) and
the Contracts tbl (Project Name, number, etc.). The user can add a new vendor
in the form with the combo box however; when I save the new record and open
the Contracts tbl, the new Vendor name field is blank. Can someone please
review the code that I used below to help me identify what's wrong?
Private Sub Combo35_NotInList(NewData As String, Response As Integer)
Dim Result
Dim Msg As String
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
'Ask the user it they wish to add the new vendor.
Msg = "'" & NewData & "' is not in the list."
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
'If the user chose Yes, start the Vendors form in data entry mode
'as a dialog form, passing the new vendor name in NewData to the
'OpenForm method's OpenArgs argument. The OpenArgs argument is used in
'Vendors form's Form_Load event procedure.
DoCmd.OpenForm "frmAddVendors", , , , acFormAdd, acDialog, NewData
Combo35.SetFocus
Response = acDataErrAdded
End If
End Sub
Vendor Form on Load event
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![Vendor Name] = Me.OpenArgs
End If
End Sub
Any assistance is greatly appreciated!
the Contracts tbl (Project Name, number, etc.). The user can add a new vendor
in the form with the combo box however; when I save the new record and open
the Contracts tbl, the new Vendor name field is blank. Can someone please
review the code that I used below to help me identify what's wrong?
Private Sub Combo35_NotInList(NewData As String, Response As Integer)
Dim Result
Dim Msg As String
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
'Ask the user it they wish to add the new vendor.
Msg = "'" & NewData & "' is not in the list."
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
'If the user chose Yes, start the Vendors form in data entry mode
'as a dialog form, passing the new vendor name in NewData to the
'OpenForm method's OpenArgs argument. The OpenArgs argument is used in
'Vendors form's Form_Load event procedure.
DoCmd.OpenForm "frmAddVendors", , , , acFormAdd, acDialog, NewData
Combo35.SetFocus
Response = acDataErrAdded
End If
End Sub
Vendor Form on Load event
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![Vendor Name] = Me.OpenArgs
End If
End Sub
Any assistance is greatly appreciated!