WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADO DAO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Delete All Records from Access Table


Question:

This is probably really simple but i seem to be having trouble - what is the best way to delete all records from one Access database table?

Answer:

;   DAO is similar to MS Access Basic...

dao = ObjectOpen("DAO.DBEngine.35")  ;<-- you may have to change for your version

ws = dao.CreateWorkspace("JetWorkspace", "admin", "")
db = ws.OpenDatabase("c:\data\access\survey template.mdb")

sqlstr = "delete * from MyTable;"      ;<-- create the delete SQL statement...

db.execute(sqlstr)                     ;<-- execute it...


ObjectClose(db)
ObjectClose(ws)
ObjectClose(dao)

Message("Debug", "End of Job")

Exit

Article ID:   W16079
File Created: 2004:03:30:15:42:46
Last Updated: 2004:03:30:15:42:46