Results 1 to 7 of 7
  1. #1
    bchi99 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    23

    set warnings autoexec


    Hi, i saved a autoexec macro to run and set warning messages to off. However, when i run a certain query, i still get an error message on data mismatches but i always click yes to make the query run and update the fields. Anyone know why the setwarnings to no isn't working?

  2. #2
    bchi99 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2014
    Posts
    23
    is it b.c the query is running on fields that are null?

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For starters, I wouldn't set warnings off and leave them that way. More info here including a possible solution:

    http://www.baldyweb.com/SQLWarnings.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I agree with Paul. I NEVER use "Set Warnings Off". I DO have a lot of error routines.

    i still get an error message on data mismatches but i always click yes to make the query run and update the fields
    I am curious why don't you fix the error? Handling errors by ignoring them is not good programming practice. If you get a low oil warning light in your car, do you just put a piece of tape over the light and ignore it?

  5. #5
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181
    Quote Originally Posted by ssanfu View Post
    I agree with Paul. I NEVER use "Set Warnings Off". I DO have a lot of error routines.


    I am curious why don't you fix the error? Handling errors by ignoring them is not good programming practice. If you get a low oil warning light in your car, do you just put a piece of tape over the light and ignore it?
    I use the "Set Warnings Off" code a lot for file imports/exports to and from Excel. Rather than confusing users with "Are you sure you want to add x number of rows to y table?" messages, I turn warnings off and have an "Import successful" vbOKOnly message at the end, and turn Warnings back on. I also use error trapping within the "Set Warnings Off/On" tags to handle any errors that may come up. A bit off topic, but there's a legitimate method of using the command.

    bchi99, if you're having data mismatches, then I don't see how you are updating very well. Can you tell us more about what data you are trying to update? What is the source? What is the destination? How are the fields named? How are the fields formatted (for example, are you trying to put a date in a number field)?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Use CurrentDb.Execute to run SQL actions and won't have to bother with SetWarnings.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by June7 View Post
    Use CurrentDb.Execute to run SQL actions and won't have to bother with SetWarnings.
    What I use.... plus it is faster - Currentdb.Execute is executed by Jet, Docmd.RunSQL is handled first by Access, then by Jet. (IIRC)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Disabling query warnings
    By Tom123 in forum Queries
    Replies: 8
    Last Post: 02-10-2014, 03:35 PM
  2. Turn OFF Warnings in Access 2010
    By taimysho0 in forum Programming
    Replies: 3
    Last Post: 01-27-2012, 05:47 PM
  3. Errors but not warnings ?
    By asearle in forum Access
    Replies: 3
    Last Post: 08-10-2011, 01:26 AM
  4. Turn warnings off
    By Mclaren in forum Programming
    Replies: 6
    Last Post: 05-03-2010, 12:07 PM
  5. Set Warnings Off
    By NMJones in forum Access
    Replies: 2
    Last Post: 04-12-2010, 03:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums