troubleshooting Question

Not In List property of combo box not adding a record to it when using another form.

Avatar of stephenlecomptejr
stephenlecomptejrFlag for United States of America asked on
Microsoft Access
1 Comment1 Solution474 ViewsLast Modified:
I got this combo box with a particular list of vendors and their addresses with contact information.
The following code does check for Not In List and then opens up another form that is tied directly to the Vendor table.
When they close out of that Vendor table I want it to update the combo box that I'm currently on in the main form.
Here is the code for the Not In List:  And in the Form Unload of Private Sub Form_Unload(Cancel As Integer)
  If IsOpen("frmReqs") Then Forms!frmReqs!cboVendor.Requery
End Sub  -  I get getting an error - Run-time error 2118 you must save the current field before you run the Requery action.
Please help.  Thank you

Private Sub cboVendor_NotInList(NewData As String, Response As Integer)

Dim Msg As String
Dim NewID As String

On Error GoTo Err_CustomerID_NotInList

    ' Exit this subroutine if the combo box was cleared.
    If NewData = "" Then Exit Sub

    ' Confirm that the user wants to add the new customer.
    Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
    Msg = Msg & "Do you want to add it?"
    If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
        ' If the user chose not to add a customer, set the Response
        ' argument to suppress an error message and undo changes.
        Response = acDataErrContinue
        ' Display a customized message.
        MsgBox "Please try again."
        DoCmd.OpenForm "frmVendor", acNormal, , , acFormAdd
        Response = -1

    End If

       Exit Sub
       ' An unexpected error occurred, display the normal error message.
       MsgBox Err.Description
       ' Set the Response argument to suppress an error message and undo
       ' changes.
       Response = acDataErrContinue
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros