Stop NotInList Error message

  • Thread starter Thread starter Tara
  • Start date Start date
T

Tara

I have a combo box that I want users to be able to add values to. In the
NotInList event I have it set to ask the user if they want to add the Agency.
If they do, it opens up the frmAddAgency form. Everything works well so
far, but the standard NotInList error message still opens once frmAddAgency
opens. How do I stop it? I have the custom message in place, so I assumed
it wouldn't appear at all.

Here's the code:

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

If MsgBox("This Agency is not currently in the list. Would you like to
add this Agency?", vbYesNo + vbQuestion) = vbYes Then
DoCmd.OpenForm "frmAddAgencies"
Else
MsgBox ("Please enter a valid Agency from the drop down box.")

End If

End Sub
Thanks,

Tara
 
Use:

Response = acDataErrAdded

and:

Response = acDataErrContinue

like:

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

If MsgBox("This Agency is not currently in the list. Would you like to
add this Agency?", vbYesNo + vbQuestion) = vbYes Then
Response = acDataErrAdded
DoCmd.OpenForm "frmAddAgencies"
Else
Response = acDataErrContinue
MsgBox ("Please enter a valid Agency from the drop down box.")

End If

End Sub
 
Thanks Arvin. I tried what you gave me, and I'm sure it's right, but I keep
getting a syntax error. I'm going to post that issue to the board too in
case you don't get a chance to check in on this post again
 
Back
Top