?
Solved

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

Posted on 2003-03-23
6
Medium Priority
?
149 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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 Month14 days, 9 hours left to enroll

770 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