Stop NotInList Error message

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
 
A

Arvin Meyer [MVP]

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
 
T

Tara

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

On Not In List Error 8
MsgBox error 9
NotInList Firing Problem 12
End If without Block If 5
Need help with this NotInList code for a combo box 4
NotInList help 3
Rename Message Box 3
Not In List Error Handling 3

Top