Suppress warnings with code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I want to use the Not In List event to launch a form to enter new
information, but I don't want the user to see the error message. I could use
a macro to disable the warnings, but I'd like to know how that can be done in
code.
Any assistance would be appreciated.

Thank you.
 
I figured it out.
Funny how a lot of things seem obvious once you know the solution.

DoCmd.SetWarnings = False
 
Hello,

I want to use the Not In List event to launch a form to enter new
information, but I don't want the user to see the error message. I could use
a macro to disable the warnings, but I'd like to know how that can be done in
code.
Any assistance would be appreciated.

Thank you.

DoCmd.SetWarnings False

before the event which triggers the error.

Actually if you write the NotInList code correctly as described in its
VBA Help, you shouldn't get any error messages in the first place!

John W. Vinson[MVP]
 
Ok, maybe "error message" wasn't the right word... I mean the message that
the new value is not in the list.
Is there a way to suppress that?
Looks like docmd.setwarnings doesn't do that; or maybe I just need to put it
somewhere else?
___

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

' Opens form to enter new location

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmNewLocation"

DoCmd.SetWarnings False
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
DoCmd.SetWarnings True

End Sub
 
Ok, I see what you mean.
I stumbled upon this solution to my question, and there are no messages
whatsoever.

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

' Opens form to enter new location

Dim stDocName As String
stDocName = "frmNewLocation"

DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acDialog

Response = acDataErrAdded

End Sub
 

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

Back
Top