Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Silverback

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    DoCmd.SetWarnings True

    before, and

    DoCmd.SetWarnings False

    after
    Hans,

    It is False Before end True after.
    Francois

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Of course!

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

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perfect! It's working just as we want it to.
    Thanks to you and Hans.
    Silverback
    Silverback

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    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.
    Regards
    John



  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Silverback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •