Run SQL

G

Graveyardblues

I have a macro that begins: Run SQL Code: delete * from "Table Name"...When
I import data into my existing Table, I need to delete any existing records
from that table. It works, but always pops up a msg saying I am about to
delete X any records... I always click yes & move on, is there any way to
keep this msg from popping up ?? I ALWAYS need to delet the prior records,
so I do not need the option of saying yes or no, I just need it to always
delete the old records & import new ones??????
Any Help appreciated....
Aaron
 
A

Allen Browne

You can avoid the message with SetWarnings.
Don't forget to turn it back on again.

To be honest, that's only half an answer. When you turn off SetWarnings, you
don't know whether the records were deleted successfully or not. A better
solution is to use the Execute method in code.

Details in this article:
Action queries: suppressing dialogs, while knowing results
at:
http://allenbrowne.com/ser-60.html
 
K

Klatuu

There are a couple of ways to do this.
The message you are getting is because SetWarnings is on (True). You can
completely disable these messages for the application using Tools, Options,
Edit/Find tab and unchecking all the boxes under confirm.

If you want to control the messages at run time depending on circumstances,
add two lines to your macro. One before the RunSQL to turn the messages off
and one after two turn them back on. Use the SetWarnings action and select
no to disable messages and yes to enable them.
 

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