?
Solved

How do you turn off the warnings in Access 2013

Posted on 2015-01-25
5
Medium Priority
?
492 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
[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
5 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40569919
0
 
LVL 51

Accepted Solution

by:
Gustav Brock earned 2000 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 58
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 51

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 38

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

Industry Leaders: 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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

765 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