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.
 
Back
Top