Fred and Tom are correct, so the question is how to proceed. The best
solution is not to mess with a setting you cannot determine.
Most often, we see people turn SetWarnings off so users do not get annoyed
with confirmation dialogs on action queries (insert, delete, or update.)
This is not a good approach. If the action query fails (records cannot be
added, removed, or altered), you get no warning, so your code is making
invalid assumptions about what it can do next.
A simple alternative is to use the Execute method instead of firing your
action query with RunSQL or OpenQuery. Example:
dbEngine(0)(0).Execute "Query1", dbFailOnError
That approach generates no confirmation message, so you do not need to mess
with SetWarnings. However, if the query fails to execute completely, it does
generate a trappable error, so your code does not blithely continue in
ignorance.
The disadvantage of the Execute method is that it does not call the
Expression Service. That means if Query1 contains a parameter such as:
[Forms].[Form1].[ClientID]
it will not work. One solution is to assign the parameter values, e.g.:
qdf.Parameters("[Forms].[Form1].[ClientID]") =
[Forms].[Form1].[ClientID]
Personally, I find it easier to build a SQL string dynamically, e.g.:
strSql = "DELETE FROM Table1 WHERE ClientID = " & _
[Forms].[Form1].[ClientID] & ";"
dbEngine(0)(0).Execute strSql, dbFailOnError
This also has the advantage that your code is independent any saved query,
and makes the database easier to maintain.
If that is not enough to convince you to use Execute rather than RunSQL, the
Execute method also gives you the opportunity to create a transaction for an
all-or-nothing result. Details and example:
Archive: Move records to another table
at:
http://allenbrowne.com/ser-37.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"MLH" <CR**@NorthState.net> wrote in message
news:sn********************************@4ax.com...
I thought I could run docmd.SetWarnings in the
immediate window with no argument and A97
would return True or False, depending on the
current setting. I was wrong.
Anybody know how to make the determination
in the immediate window?