NotInList How to eliminate System Generated Error

1

10SNUT

I am using the following code. Everything works EXCEPT after th
message I put in the code, I get the system generated message: "Th
item you selected is not in the list - Please select...." How do
eliminate that message??


I have LimitToList set to YES, and this code is in the NotInLis
property.



Option Compare Database
Option Explicit

Private Sub ContractorName_NotInList(NewData As String, Response A
Integer)


If MsgBox("Do you want to add '" _
& NewData & "' to the list of contractors?", _
vbOKCancel, "Add New Item") = vbOK Then

' Remove new data from combo box so control can be requeried
' after the Form1 form is closed
DoCmd.RunCommand acCmdUndo

' Display form to collect data needed for the new record
DoCmd.OpenForm "Form1", acNormal, , , acAdd, acDialog
NewData

'Continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub

Thanks for your assistance in advance,
10SNU
 
R

RuralGuy

10SNUT said:
I am using the following code. Everything works EXCEPT after the
message I put in the code, I get the system generated message: "The
item you selected is not in the list - Please select...." How do I
eliminate that message??


I have LimitToList set to YES, and this code is in the NotInList
property.



Option Compare Database
Option Explicit

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


If MsgBox("Do you want to add '" _
& NewData & "' to the list of contractors?", _
vbOKCancel, "Add New Item") = vbOK Then

' Remove new data from combo box so control can be requeried
' after the Form1 form is closed
*** JUST REMOVE THIS CODE ***
*** DoCmd.RunCommand acCmdUndo
' Display form to collect data needed for the new record
DoCmd.OpenForm "Form1", acNormal, , , acAdd, acDialog,
NewData

'Continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

End Sub

Thanks for your assistance in advance,
10SNUT

Hi 10SNUT,

I answered it of the other thread. Thanks for posting your code
and the problem.

HTH
 
Top