INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

SetWarnings not Turning Warnings back on

SetWarnings not Turning Warnings back on

(OP)
I often have vba code that runs action queries and I want the warnings temporarily suppressed during their execution, so pretty much the standard usage for the SetWarnings method.
So at the beginning I put in:
DoCmd.SetWarnings (WarningsOff)
And at the end I put in
DoCmd.SetWarnings (WarningsOn)

Sometimes this seems to work, but most of the time the warnings stay off, which gives me problems. Does anyone know why this doesn't function? In fact, it might be that the only time it works right is if it's in a macro instead of code I find it suspicious that it doesn't automatically capitalize warningson and warningsoff, like the editor doesn't recognize them as special words.

RE: SetWarnings not Turning Warnings back on

There is no such constants as WarningsOn and WarningsOff. It is a parameter for you to pass TRUE or FALSE. The reason is works some of the time is that it is evaluating "warningsOff" to something other than -1 (true). It does not comeback on because "warningson" will resolve to something other than TRUE.

RE: SetWarnings not Turning Warnings back on

BTW google "option explicit". If you require variable declaration this would have not been a problem. When you tried to run the code it would have told you that "warningson" is an undeclared variable. In other words it thinks warningson is variant variable.

RE: SetWarnings not Turning Warnings back on

(OP)
That makes sense. So I should just be able to put True or False, or 0 or -1 in there as the case may be. Thanks.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close