Q: determining current "Show Warnings" state

A

A C

Hi

Is there a way to determine Access's current "Show Warnings" state? I would
like to turn warnings off, run my code, then restore the warnings back to
what they were prior to me running the code.

Thanks in advance
A
 
G

Guest

Hi I hope you can add the following to turn warnings Off
and On:

DoCmd.SetWarnings Off
DoCmd.SetWarnings On
 
D

Douglas J. Steele

AFAIK, there's no way to check what it currently is. However, it's your
application, so you should feel free to set them to whatever's appropriate
for the application.

The advice in the other response is slightly off. It's DoCmd.SetWarnings
False and DoCmd.SetWarnings True, not On and Off.

Of course, if you use the Execute method of the DAO Database object, there's
no need to worry about this, as it doesn't pop up the messages you get when
you use RunSQL.
 
A

A C

Really, no way to check?! Crickey.

I take your point about "my" application, but still think it is better to
maintain the status quo at all times. For example I might have a "utility"
function that I use all the time, and part of that util function generates
warnings that it wants to supress. Its "purpose" is, for example, to delete
some records, its "purpose" is *not* to adjust the system state. My calling
routine may (for whatever reason) specifically want warnings ON. So this
rules out "cleanly" using the utility routine as a nested function as my
system state prior to calling the util function is now different to the
system state post calling the util function despite the fact its purpose was
only to delete records and not to adjust my system state.

The only way to avoid this, assuming there is no way to check the warnings
state, is to
1. Adjust the utils code to take as a parameter an indication of whether it
should reinstate warnings or not; or
2. Reset the warnings state to ON again (in this example) immediatelly after
calling the util function.

Neither seems clean to me, 1 is a fudge and 2 is fixing an accidental side
effect.


Thanks for the help everyone.
A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top