?
Solved

Can I turn off the notifications in Access using VB?

Posted on 2013-01-17
1
Medium Priority
?
459 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
[X]
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
1 Comment
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 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