delete all records in a table

  • Thread starter Thread starter rex28
  • Start date Start date
R

rex28

Guest
Hi All

I try to write some VBA code to delete all records in the existing table and use Transferspreadsheet command to paste new record to it. Can anyone help me out this? It is very appreciated.

Thanks

Rex
 
Here's a simple solution:
---
DoCmd.RunSQL "DELETE * FROM <<enter table name>>;"

DoCmd.TransferSpreadsheet acImport, <<enter spreadsheet type ie. acSpreadsheetTypeExcel9>>, "<<enter table name>>", "<<enter directory path where spreadsheet is stored>>", True, "<<enter spreadsheet range if applicable>>"
----

The areas that are marked "<< >>" mean that's where you enter in the information specific to your environment.
 
Hi- I've used a similar set of code for deleting and refreshing a table, using sql code to delete the data from the original table (using setwarnings to off) then using an append sql stmt to add the data from a secondary table.
 

Users who are viewing this thread

Back
Top Bottom