Suppress the "You are update to update..." message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some SQL code that gets executed upon clicking a button. The SQL code
updates a table. After the button is clicked, a message pops up stating "You
are about to update 1 record" and asks for confirmation.

How do I suppress this message?

Thanks.
 
Hi, Shael.
How do I suppress this message?

The best (and fastest) way is to use the Execute method to execute the SQL
statement, with the dbFailOnError argument to catch (and roll back) any
errors. For example:

CurrentDb().Execute "UPDATE MyTable SET CloseDate = Date();",
dbFailOnError

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
And if you want to you could use:

DoCmd.SetWarnings False
'-> run the sql here
DoCmd.SetWarnings True

But as Gunny stated it's better to use the currentdb.execute..

hth
 
Shael said:
I have some SQL code that gets executed upon clicking a button. The SQL code
updates a table. After the button is clicked, a message pops up stating "You


The best way is to use the Execute method instead of RunSQL.
If you are locked into RunSQL, then try using SetWarnings.
If you are not familiar with those methodsm check VBA Help
for details.
 
Maurice said:
DoCmd.SetWarnings False
'-> run the sql here
DoCmd.SetWarnings True
Don't.

But as Gunny stated it's better to use the currentdb.execute..

Far, far better to use currentdb.execute

I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
command instead of docmd.runsql. For ADO use
CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
adCmdText

If you're going to use docmd.setwarnings make very sure you put the
True statement in any error handling code as well. Otherwise weird
things may happen later on especially while you are working on the
app. For example you will no longer get the "Do you wish to save your
changes" message if you close an object. This may mean that unwanted
changes, deletions or additions will be saved to your MDB.

Also performance can be significantly different between the two
methods. One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds. As always YMMV.

Tony


--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top