• Switching off Access warning messages

    Author
    Topic
    #464003

    My development DB uses action queries which generate Access warning when they are run. I would like to switch these warnings off (Tools | Options | Edit/Find | Record Changes and/or ActionQueries) but the options seem to be at Access level rather than at individual DB level.
    Is it possible to uncheck these options by macro/VB when my DB is started and switch them back to their previous state on exit from the DB?
    If so, can a lounger explain how, please?
    Thanks
    Silverback

    Viewing 2 reply threads
    Author
    Replies
    • #1186317

      If you are using VBA add a line before the line that runs the action query :
      DoCmd.SetWarnings False

      To reset the warnings use
      DoCmd.SetWarnings True

      If you don’t use VBA, you can execute this lines in the Immediate window (CTRL G)

      • #1186327

        Perfect! It’s working just as we want it to.
        Thanks to you and Hans.
        Silverback

    • #1186318

      Edited because of stupid error – thanks, Francois!

      If you run the queries from code, insert a line

      DoCmd.SetWarnings False

      before, and

      DoCmd.SetWarnings True

      after the code that executes an action query. The advantage is that it doesn’t change the user’s preference, just suppresses the warnings temporarily.

      Another option is to use DAO to execute the action queries:

      CurrentDb.Execute “NameOfActionQuery”

      will execute a query without generating a warning. But this won’t work if your query has parameters or references to controls on forms – DAO can’t display a parameter prompt and it doesn’t “know” about forms.

      • #1186320

        DoCmd.SetWarnings True

        before, and

        DoCmd.SetWarnings False

        after

        Hans,

        It is False Before end True after.

        • #1186321

          Of course!

          Thanks, Francois! I’ve corrected my previous reply.

    • #1186692

      The alternative option for this is to use the SetOption and GetOptions methods.

      Code:
       
      Application.SetOption "Confirm Action Queries", False
      Application.SetOption "Confirm Record Changes", False
      

      This code turns off the warning messages in the database.

      You can use the GetOption method to find out the initial values, store them somewhere, then put them back to the original values when the database closes.

      • #1187057

        John
        Thanks for your tip. I’ve used the method advised by Francois and Hans, but have filed your tip on how to read and restore these options for possible future use.
        Silverback

    Viewing 2 reply threads
    Reply To: Reply #1186321 in Switching off Access warning messages

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel