Solved

delete * from tables?

Posted on 2012-03-23
4
472 Views
Last Modified: 2012-03-23
Is there a simple to delete every records from multiple tables?
Then I need to compact the database to recreate the auto number start from 1.
0
Comment
Question by:dkim18
4 Comments
 
LVL 18

Assisted Solution

by:Cluskitt
Cluskitt earned 50 total points
ID: 37757841
Select all the tables you want to delete, copy then with "Structure only" option (no data), delete the original ones, rename the new ones (easy to delete the "copy of" part)
0
 
LVL 6

Accepted Solution

by:
wshark83 earned 350 total points
ID: 37757869
you can have multiple statements as per below :

DoCmd.RunSQL ("Delete * from <tablename1>")
DoCmd.RunSQL ("Delete * from <tablename2>")
DoCmd.RunSQL ("Delete * from <tablename3>")
DoCmd.RunSQL ("Delete * from <tablename4>")

this is quicker in deleted all the rows from the table and keeps the table structure intact
0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 50 total points
ID: 37758001
Running the delete query will not restart the autonumbers from scratch, Cluskitt's method will do this for you.

But I would argue that this is a waste of time.  Autonumber ID fields should not be visible to your users anyway, so restarting from 1 is not necessary.  If you need to display a field to users that starts at one, use a numeric value that you can manipulate the way you want to.
0
 
LVL 14

Assisted Solution

by:VBClassicGuy
VBClassicGuy earned 50 total points
ID: 37758590
If you must compact the database, use this:

http://support.microsoft.com/kb/273956
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now