Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete all records within a table, no exceptions. 1

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
Using Access 2000, I would like to delete all records contained within tbl_FileName without exception. I will be keeping the table and it's structure, just want the records gone. What would be the easiest, quickest way to accomplish this with VBA ?

Thank you for any advice.
 
A delete query maybe?

sql="DELETE * from tbl_FileName"
docmd.runsql sql
 
DELETE field1, field2, field3, ... ... field1000
FROM tableName

Or if using query designer just create a query to select each column then change it to a delete.

If you want to avoid deleting certain values add a where clause.

HTH,

Alex



It's a magical time of year in Philadelphia. Eagles training camp marks the end of another brutal season of complaining about the Phillies.
 
Oh yeah, you have to save the query and then use docmd.openquery to run it. I prefer jadams method myself, but thought that openquery would be a bit easier. Either way, I would list all fields rather than using the *.

Good Luck,

Alex


It's a magical time of year in Philadelphia. Eagles training camp marks the end of another brutal season of complaining about the Phillies.
 

For the good old DAO way
CurrentDB.Execute "DELETE FROM tbl_FileName"

And ADO way (Access 2000 and above)
CurrentProject.Connection.Execute "DELETE FROM tbl_FileName",,129
 
The arguments after DELETE are just place holders when you are dealing with only one table. The DELETE statement removes whole records regardless of the arguments that you use.
Code:
DELETE From myTable
DELETE * From myTable
DELETE fld1 From myTable
DELETE fld1, fld2, fld3, fld4, ... From myTable
All do exactly the same thing which is delete all rows from the table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top