I have a Combo Box and have added an Event (VBA Code) so that users may add a value to the Combo Box List. I 'did' set the "Limit to List" to YES.
The Event "does run" and users "can add" a new value to the list. But if the user wants to simply add a value to the top form without adding it to the subform (combo box list), they can't do that. I thought that by answering NO on the button the user would be able to keep the typed value in the text box (without adding it to the list) and then tab to the next control. But the box keeps popping up and allowing only 1)something to be added to the list,or 2)the text box entry to be deleted so that the user may move on and tab to the next control.
How can I make the NO button work so that the user can add a value to the text box (top form) without adding it to the list?
Here is my code. Any guidance would be greatly appreciated, as I have spent about 5 hours today just trying to figure this out.
Private Sub Customer_Name_NotInList(NewData As String, Response As Integer)
On Error GoTo Customer_Name_NotInList_Err
' Add a new record to the Customer Name table
' and requery the Customer Name combo box
Dim NewName As Integer, MsgTitle As String, MsgDialog As Integer
Const MB_YESNO = 4
Const MB_ICONEXCLAMATION = 48
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
'Make sure the user really wants to add it
MsgTitle = "Customer Name is not on the list"
MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
NewName = MsgBox("Do you want to add the new Customer Name?", MsgDialog, MsgTitle)
If NewName = IDNO Then
Response = acDataErrContinue
Else
DoCmd.OpenForm "Customer Name Input Form", acNormal, , , acAdd, acDialog
Response = acDataErrAdded
End If
Customer_Name_Exit:
Exit Sub
Customer_Name_NotInList_Err:
MsgBox Err.Description
Resume Customer_Name_Exit
End Sub
The Event "does run" and users "can add" a new value to the list. But if the user wants to simply add a value to the top form without adding it to the subform (combo box list), they can't do that. I thought that by answering NO on the button the user would be able to keep the typed value in the text box (without adding it to the list) and then tab to the next control. But the box keeps popping up and allowing only 1)something to be added to the list,or 2)the text box entry to be deleted so that the user may move on and tab to the next control.
How can I make the NO button work so that the user can add a value to the text box (top form) without adding it to the list?
Here is my code. Any guidance would be greatly appreciated, as I have spent about 5 hours today just trying to figure this out.
Private Sub Customer_Name_NotInList(NewData As String, Response As Integer)
On Error GoTo Customer_Name_NotInList_Err
' Add a new record to the Customer Name table
' and requery the Customer Name combo box
Dim NewName As Integer, MsgTitle As String, MsgDialog As Integer
Const MB_YESNO = 4
Const MB_ICONEXCLAMATION = 48
Const MB_DEFBUTTON1 = 0, IDYES = 6, IDNO = 7
'Make sure the user really wants to add it
MsgTitle = "Customer Name is not on the list"
MsgDialog = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON1
NewName = MsgBox("Do you want to add the new Customer Name?", MsgDialog, MsgTitle)
If NewName = IDNO Then
Response = acDataErrContinue
Else
DoCmd.OpenForm "Customer Name Input Form", acNormal, , , acAdd, acDialog
Response = acDataErrAdded
End If
Customer_Name_Exit:
Exit Sub
Customer_Name_NotInList_Err:
MsgBox Err.Description
Resume Customer_Name_Exit
End Sub