Suppress Delete Query Messages

honor401

Registered User.
Local time
Yesterday, 21:58
Joined
Aug 26, 2004
Messages
11
I have a delete query that I would like to run on a table that would delete all records before I import into that table again.
I would like this to happen with out any user intervention at all like "you are about to delete 50 records"
how could that be achieved?
Also is there a better way than a delete query
I want to remove data and leave table structure.
thanks in advance
Honor401
 
no better way then a delete query

before the code to run the query put this:

DoCmd.SetWarnings False

then, after the query code put this:

DoCmd.SetWarnings True


Note* make sure you set the warnings back to true as this will turn off all of the warnings for the entire db and you can do some very damaging things without even knowing it...

HTH,
Kev
 
I had thought there was an option in the query design to allow you to suppress this kind of warning but it has been a while since I've used Access on a daily basis so I shall no doubt be corrected by those that know more about these things.... :)

The following VBA should work for you with a few obvious changes like the name of the table you want to delete records from, and could form the behaviour of the onClick button on a form if you want. It will leave the structure of the table unchanged.

Sub deleteAllRecords()

DoCmd.SetWarnings False
DoCmd.RunSQL "delete * FROM tblXxxxx;"
DoCmd.SetWarnings True

End Sub
 
Great thanks to the both of you. That will help out a lot...
thanks again,
honor401
 

Users who are viewing this thread

Back
Top Bottom