Solved

Can I turn off the notifications in Access using VB?

Posted on 2013-01-17
1
391 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

20 Experts available now in Live!

Get 1:1 Help Now