Solved

Can I turn off the notifications in Access using VB?

Posted on 2013-01-17
1
408 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 - Access MVP) 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now