Solved

How do you turn off the warnings in Access 2013

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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 …
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…

803 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