Microsoft Knowledge Base Email Alertz

KBAlertz.com: This article shows you how to use the

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 229802 - Last Review: April 6, 2007 - Revision: 6.1

How to use SetOption to disable warning messages in an Access Application

This article was previously published under Q229802
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb or .accdb).

SUMMARY

This article shows you how to use the Application.SetOption method to disable warning messages in an Access application.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Action queries and other processes that append, delete, or modify data typically present the user with a warning that the data is about to be modified. In a run-time application, however, it is often desirable to disable the warnings because checks and precautions are usually beyond the user's control.

You can accomplish this by using the SetWarnings method of the DoCmd object, but you may prefer to disable warnings for the entire application. To do that, you can use the SetOption method of the Application object. However, if you do so, you should also turn the warnings back on as the application quits.

To do this in a simple, one-form application, follow these steps:
  1. Start Access, and then create a blank database named TestRun.
  2. Import the Customers table from the Northwind.mdb sample database.
  3. Create a new form in Design view, and then add an unbound combo box to the detail section.
  4. Set the following properties for the combo box:
       Name: cboCountry
       Row Source: SELECT DISTINCT Customers.Country FROM Customers ORDER BY Customers.Country; 
    					
  5. Add a command button to the detail section of the form and name it cmdDelete.
  6. Set the OnClick property of the command button to the following event procedure:
    DoCmd.OpenQuery "qryDeleteCustomers"
    					
  7. Close the Visual Basic Editor.
  8. Save the form as DeleteCustomers, and then close it.
  9. Create a new query in Design view, and then add the Customers table.
  10. In Access 2002 or in Access 2003, click Delete Query on the Query menu.

    In Access 2007, click Delete in the Query Type group on the Design tab.
  11. Drag the asterisk (*) from the field list to the first column of the query design grid, and then drag the Country field to the second column.
  12. In the Criteria row of the Country column, type the following:
       Forms![DeleteCustomers]![cboCountry] 
    					
  13. Save the query as qryDeleteCustomers, and then close it.
  14. Open the DeleteCustomers form in Form view.
  15. Select a country from the combo box, click the command button, and note the warning that appears. Click No in the warning dialog box.
  16. Open the form in Design view, and then on the toolbar, click the Code button.
  17. In the Code window, type or paste the following procedures:
    Private Sub Form_Load()
    
       Application.SetOption "Confirm Action Queries", 0
       Application.SetOption "Confirm Document Deletions", 0
       Application.SetOption "Confirm Record Changes", 0
    
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    
        Application.SetOption "Confirm Action Queries", 1
        Application.SetOption "Confirm Document Deletions", 1
        Application.SetOption "Confirm Record Changes", 1
    
    End Sub
    					
  18. Close the Visual Basic Editor, and then save and close the form.
  19. Open the DeleteCustomers form, select a country, and then click the command button.

    Note that no warning dialog appears.
In this example, the application's confirm options are disabled when the DeleteCustomers form is loaded and re-enabled when it is unloaded. In a more elaborate application, you might carry out the same actions in a startup form or switchboard.

APPLIES TO
  • Microsoft Office Access 2007
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbprogramming kbhowto KB229802
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please