Delete all records on a table

S

Shiner452

I want to have a button on my form delete all records on a table as th
table is appended from a query. The query is run multiple times and
would like to have the table clear every time the query is run. I
there any way I can delete all the records in the table with a click o
a button? Thank
 
J

John Vinson

Is
there any way I can delete all the records in the table with a click of
a button?

A Delete query:

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

Note that 1) you will need to regularly Compact your database if you
do this, since space occupied by deleted records is not recovered, and
2) it's often better to avoid this kind of "scratch" table entirely if
possible; you can base a Report, an Export, or another Query on a
Select query without having to write the records out to a table.
 

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