Clearing a table

  • Thread starter Thread starter Bob Parr
  • Start date Start date
B

Bob Parr

Is there an easy way to delete the contence of a table? I know I can go
through one at a time and delete records, but is that the only way?

Bob
 
You can do this with a very simple query - just create a new query and click
view-SQL View and paste in the following, then change 'MyTable' to your
table name.

Delete * from MyTable;

As long as you haven't turned warnings off, it will prompt you to be sure
you really want to do this -
 
Bob said:
Is there an easy way to delete the contence of a table? I know I can go
through one at a time and delete records, but is that the only way?

You can click on the first record's record selector, hold
down the Shift key, scroll to the end of the table and click
on the last record's record selector, then hit the Delete
key.


Or you could run a DELETE query.
 
I am sorry, I should have been clearer. I want to do this from VBA. and
What is a delete query?

Bob
 
Bob said:
I am sorry, I should have been clearer. I want to do this from VBA. and
What is a delete query?

A delete query is a query that deletes records in a table.

The VBA code to run a query could look something like:

DIm db As Database
Dim strSQL As String
Set db = CurrentDb()
strSQL = "DELETE * FROM thetable"
db.Execute strSQL, dbFailOnError
Set db = Nothing
--
Marsh
MVP [MS Access]


 
Sam said:
Or more simply...
DoCmd.RunSQL "DELETE * FROM tblMyTable"


Right!

It's just so rare that I want to see those are you sure
confirmation prompts that I almost always use the execute
method.
--
Marsh
MVP [MS Access]


 
Back
Top