Macro that will clear data from table

Posted on 2008-02-02
Medium Priority
Last Modified: 2013-11-27
Hi experts,
I need a way to clear records from a data table (maybe a macro) - intended to use as a rollover of a database for a new cycle.  More than one table needs to be cleared, so I'm guessing a separate macro would be needed for each table - or can this be achieved with just one process?
Question by:mloricha
  • 2
LVL 34

Accepted Solution

Mike Eghtebas earned 2000 total points
ID: 20808058

In on click event of a button, have:

CurrentDB.Execute "Delete * From Tabl1"
CurrentDB.Execute "Delete * From Tabl2"
CurrentDB.Execute "Delete * From Tabl3"

Make sure to include tables with many (with foreign key) first.

LVL 13

Expert Comment

ID: 20808149
If this is an occasional thing, you could just open each table, select All (Ctrl + A) and delete.

Careful about deleting data from tables, its kind of permanent, don't make a button too easy and without plenty of warning.

Author Comment

ID: 20808206
Home eghtebas.  Works a treat (and thanks for the tip re table with many.
Best regards, Lisa
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 20808890
My pleasure.

Also, for future reference:

CurrentDB.Execute "Delete * From [C:\Folder1\TestFile.mdb].[Tabl1]"
could be executed to manipulate TestFile.mdb remotely.


Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question