Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Can I turn off the notifications in Access using VB?

Posted on 2013-01-17
1
426 Views
Last Modified: 2013-01-17
Even when I choose set warnings to off in my code, I still get the notifications when I run an update query.  Is there another method to turn these off?

This database could be accessed by multiple people across my organization, I do not want to have to have them choose this in a different location.
0
Comment
Question by:gracie1972
1 Comment
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 38789515
NOTE:  Be EXTREMELY careful with SetWarnings = False in VBA code.  If your forget to execute a SetWarnings True ... and/or you code errors out ... leaving a False condition in effect ... you will run into a load of other undesirable issues ... such as ...

You open a form in Design view .... you make some changes ... you decide NOT to keep those changes ... you click the Close button ... expecting to see a WARNING message asking Do you want to ....
You WILL NOT see that message and the changes will be saved ... if a prior SetWarnings False is still in effect.  There are many other situations.


A MUCH safer approach is using the Exectute method of CurrentDB. This avoids the annoying warnings prompt altogether, and further allows you to trap unexpected errors, via the dbFailOnError option.

Example:

Function mCurrentDbExecuteSeveralQueries()

' some code here

Dim X1 As Long, X2 As Long, X3 As Long
On Error GoTo YourFunctionName_Error

With CurrentDb
      .Execute "YourActionQuery1", dbFailOnError
       X1 = .RecordsAffected ' tells you how many records were processed
      .Execute "YourActionQuery2", dbFailOnError
       X2 = .RecordsAffected ' tells you how many records were processed
      .Execute "YourActionQuery3", dbFailOnError
       X3 = .RecordsAffected ' tells you how many records were processed
    ' and so on ....
End With

YourFunctionName_Exit:
    Exit Function

YourFunctionName_Error:
   ' Your error handling code here
Resume YourFunctionName_Exit

End Function

mx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question