stephenlecomptejr
asked on
Not In List property of combo box not adding a record to it when using another form.
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.Re query
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(NewDat a 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."
Else
DoCmd.OpenForm "frmVendor", acNormal, , , acFormAdd
Response = -1
End If
Exit_CustomerID_NotInList:
Exit Sub
Err_CustomerID_NotInList:
' 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
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.Re
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(NewDat
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."
Else
DoCmd.OpenForm "frmVendor", acNormal, , , acFormAdd
Response = -1
End If
Exit_CustomerID_NotInList:
Exit Sub
Err_CustomerID_NotInList:
' 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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.