Solved

How do you turn off the warnings in Access 2013

Posted on 2015-01-25
5
427 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 34

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 35

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

808 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