combo box OnNotInList Event Procedure problem

M

Madeleine

using OnNotInList Event Procedure for adding a value to combo box. Reference
KB article 197526 which gives code to answer yes no to MSGBox "add new value
to list" If ans is "No" uses acDataErrContinue function (? not sure if that
is a function). That works okay. the acDataErrDisplay also works fine.
However, if the ans is "Yes" it goes to acDataErrAdded, and that calls up my
form to add the new value. But after I enter value, I keep getting the error
that the text isn't in the combo box list and it will not add it. The
references I consulted say it should circumvent the condition set in
properties for the combo box (Limit to List=yes). Is the term acDataErrAdded
incorrect, as I said, I get the proper response with acDataErrDisplay and
acDataErrContinue? I don't know what I am doing wrong. My apologies if I am
using incorrect terminology; I am new to VBA. Thanks in advance for any
advice.
 
F

fredg

using OnNotInList Event Procedure for adding a value to combo box. Reference
KB article 197526 which gives code to answer yes no to MSGBox "add new value
to list" If ans is "No" uses acDataErrContinue function (? not sure if that
is a function). That works okay. the acDataErrDisplay also works fine.
However, if the ans is "Yes" it goes to acDataErrAdded, and that calls up my
form to add the new value. But after I enter value, I keep getting the error
that the text isn't in the combo box list and it will not add it. The
references I consulted say it should circumvent the condition set in
properties for the combo box (Limit to List=yes). Is the term acDataErrAdded
incorrect, as I said, I get the proper response with acDataErrDisplay and
acDataErrContinue? I don't know what I am doing wrong. My apologies if I am
using incorrect terminology; I am new to VBA. Thanks in advance for any
advice.

Did you requery?
Here is an example.

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

If MsgBox("This person is not in the Volunteer list." & vbNewLine _
& "Would you like to add this name to the list?", vbInformation +
vbYesNo, "Notincluded in the Volunteer list.") = vbYes Then
Me!VolName = Null
DoCmd.OpenForm "frmVolunteerInfo", , , , acFormAdd, acDialog
Me!VolName.Requery
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub
 
Top