Update Query Warning Message

  • Follow


I have a macro that will import a series of text files and then perform some 
Delete Queries...how can I stop the warning box that comes up and notifies 
you that you are about to delete records from your table?

Thanks!


0
Reply John 10/26/2007 8:36:00 PM

On Fri, 26 Oct 2007 15:36:00 -0500, John W wrote:

> I have a macro that will import a series of text files and then perform some 
> Delete Queries...how can I stop the warning box that comes up and notifies 
> you that you are about to delete records from your table?
> 
> Thanks!

Using Macro's?

Macro SetWarnings False
Macro Run Query "Delete Query Name"
Macro SetWarnings True

Using code, it would be:

DoCmd.SetWarnings False
DoCmd.OpenQuery "QueryName"
DoCmd.SetWarnings True
-- 
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
Reply fredg 10/26/2007 8:49:59 PM


There are a couple of ways you can do this.  

Calling the queries by using CurrentDb.Execute will work as well as using 

DoCmd.SetWarnings False
...do your queries
DoCmd.SetWarnings True

but if you do that, be sure to have an error handler and put the 
DoCmd.SetWarnings True in the first line of your error handler or else you 
might find yourself without warnings at all.
-- 
Bob Larson
Access World Forums Super Moderator
____________________________________
If my post was helpful to you, please rate the post.


"John W" wrote:

> I have a macro that will import a series of text files and then perform some 
> Delete Queries...how can I stop the warning box that comes up and notifies 
> you that you are about to delete records from your table?
> 
> Thanks!
> 
> 
> 
0
Reply Utf 10/26/2007 8:50:01 PM

Thanks - I knew it had to be simple!

"fredg" <fgutkind@example.invalid> wrote in message 
news:1owzq0lrqc4vk$.7cieyaer4gqa$.dlg@40tude.net...
> On Fri, 26 Oct 2007 15:36:00 -0500, John W wrote:
>
>> I have a macro that will import a series of text files and then perform 
>> some
>> Delete Queries...how can I stop the warning box that comes up and 
>> notifies
>> you that you are about to delete records from your table?
>>
>> Thanks!
>
> Using Macro's?
>
> Macro SetWarnings False
> Macro Run Query "Delete Query Name"
> Macro SetWarnings True
>
> Using code, it would be:
>
> DoCmd.SetWarnings False
> DoCmd.OpenQuery "QueryName"
> DoCmd.SetWarnings True
> -- 
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail 


0
Reply John 10/26/2007 9:23:11 PM

"John W" <jw2554@yahoo.com> wrote:

>I have a macro that will import a series of text files and then perform some 
>Delete Queries...how can I stop the warning box that comes up and notifies 
>you that you are about to delete records from your table?

Don't use Setwarnings, it's too dangerous.

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/
0
Reply Tony 10/27/2007 3:45:57 AM

4 Replies
1319 Views

(page loaded in 1.888 seconds)


Reply: