Deleting Records

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

Guest

The following solution was given by John Vinson for deleting all records.

Private Sub cmdEraseData_Click()
DoCmd.RunSQL "DELETE * FROM tablename;"
End Sub

I am using this to empty a temporary table and I don't want the warning
message about deleting x number of records to display to the user. How can I
supress this message and keep the ball bouncing? Thanks.
 
apollo,

DoCmd.SetWarning False
DoCmd.RunSQL "Delete * ....
DoCmd.SetWarnings True

or you can use the Execute method

CurrentDb.Execute "DELETE * ....", dbFailOnError

Brian
 
Hi Apollo, use the enter the following prior to running the SQL code:

DoCmd.SetWarnings False

WARNING, be sure to set the warnings to TRUE before exiting the sub because
this will turn off all of your warnings.
 
Thanks, that worked great. This discussion group is a big help when you hit a
wall on stuff. Thanks again.
 

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

Back
Top