Solved

How do you turn off the warnings in Access 2013

Posted on 2015-01-25
5
364 Views
Last Modified: 2015-02-09
Hi Experts,
I have the following code below to load data to a datasheet, but every time I close the form I get a warning message asking If I want to save changes to my queries.  I tried setting the warnings to off, but that didn't solve the issue.
How can I solve this issue?

Private Sub LoadAvailableTechs()
    DoCmd.SetWarnings False
    Dim pSQL As String

    pSQL = "SELECT * FROM Staging_Table ORDER BY Staging_Table.Tech_Name"
    
    Me.dataAvailabilitySubform.SourceObject = "Query.qryStagingTable"
    Me.dataAvailabilitySubform.Form.RecordSource = pSQL
    Me.dataAvailabilitySubform.Requery
      
    
    Me.dataAvailabilitySubform.Form.AllowEdits = True
    Me.dataAvailabilitySubform.Form.AllowAdditions = False
    Me.dataAvailabilitySubform.Form.AllowDeletions = False
    DoCmd.SetWarnings True
End Sub

Open in new window




Thanks in advance,
mrotor
0
Comment
Question by:mainrotor
5 Comments
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40569919
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40570055
You need to have them turned off until the form is closed:

    DoCmd.SetWarnings False
    ' Open form.
    '     Use form ...
    ' Close form
    DoCmd.SetWarnings True

/gustav
0
 
LVL 57
ID: 40570297
Or do a close on the form explicitly using the arguments acSaveNo or acSaveYes.

 acSavePrompt is the default if not specified, which is the prompt you get when you go to close and there are changes.

 No will discard all changes, yes will save them without a prompt.

Jim.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40570317
As I recall it, that isn't enough for a datasheet.
If you rearrange colums, it will prompt you before closing.

/gustav
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40570750
DoCmd.SetWarnings False is extremely dangerous.  When you use it in code to turn off warnings caused by Action queries, be certain to turn the warnings back on immediately after.  In fact, this setting is so dangerous that when ever I set warnings off, I set the hourglass on and vice versa.  This gives me a visual clue that my code to turn them back on was interrupted.

Leaving warnings off, can result in loss of changes to objects you modified in design view since if you close without specifically saving first, Access will silently discard your changes.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

12 Experts available now in Live!

Get 1:1 Help Now