Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Whats a quick & easy way to delete all records from a table?

Posted on 2003-03-23
6
Medium Priority
?
150 Views
Last Modified: 2010-04-07
Whats a simplified, quick, & easy way to delete all records from a table?

My databasename is Wrong.mdb, my table name is MISSED_QUESTIONS

0
Comment
Question by:Gmoney
6 Comments
 
LVL 4

Expert Comment

by:TomLaw1999
ID: 8191050
Perhaps something like this

adodc1.Recordset.MoveFirst

Do While Not Adodc1.Recordset.EOF
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
Loop

0
 
LVL 2

Expert Comment

by:Sweat
ID: 8191068
Gmoney,

An easier and faster SQL way is:


  ado/or/dao object.Execute ("DELETE * From yourtable")

Using either ADO or DAO.

No looping required.  Without any WHERE portion of the SQL everything will be selected.

Sweat

0
 
LVL 2

Accepted Solution

by:
Sweat earned 200 total points
ID: 8191072
Gmoney,

Didn't see your db and table info.

Wrong.mdb, my table name is MISSED_QUESTIONS

  ado/or/dao.Execute ("DELETE * From MISSED_QUESTIONS")

Sweat

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 28

Expert Comment

by:vinnyd79
ID: 8191226
i don't think you need the *

This should work

' add reference to Microsoft ActiveX Data Objects Library
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Wrong.mdb"
cn.Open
cn.Execute "Delete From MISSED_QUESTIONS"
cn.Close
Set cn = Nothing
0
 

Author Comment

by:Gmoney
ID: 8191444
Your code worked the best, thanks Sweets!
0
 
LVL 2

Expert Comment

by:Sweat
ID: 8191712
Gmoney,

Actually it's Sweat, but thanks for the points.

Sweat

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

580 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