Delete Records with Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
Does anyone know how I can delete all records from a table using code, while not harming the table format?
Thank you, MaryF
 
A Delete query will do this.

Add the table to the query builder then select Query | Delete query from the
menu.

The SQL will look like:

DELETE FROM TableName



--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



MaryF said:
Hello,
Does anyone know how I can delete all records from a table using code,
while not harming the table format?
 
DoCmd.RunSQL "DELETE * FROM tempOpen;"

Marc

MaryF said:
Hello,
Does anyone know how I can delete all records from a table using code,
while not harming the table format?
 
You can create a delete query. Add the table to the query, set the field
entry to * rather than individual fields and keep the criteria section
empty. This will delete ALL the data and not the structure of the table.
Note: This is permanent and can not be undone, so you must make sure this is
what you really want to do.

The query once created can be connected to a command button which can be
executed upon clicking if you need this on a continual basis, such as
removing the content from a temporary table in order to add new records to
be processed.

--
G Vaught

MaryF said:
Hello,
Does anyone know how I can delete all records from a table using code,
while not harming the table format?
 
Thank you too, GVaught, for your helpful reply. I really appreciate all of the assistance I received. :0) Mary
 
Back
Top