Using SQL to delete records

yhgtbfk

Registered User.
Local time
Today, 20:16
Joined
Aug 30, 2004
Messages
123
I use the following code

Set rst = CurrentDb.OpenRecordset("SELECT * FROM table;")
With rst
.Delete
End With

The problem is, this only deletes the first record.
Whats the best way to loop this/do this? (shortest code possible)
 
You would need to loop through the recordset if you wanted to delete every record. This is not a good way to accomplish the task though. A delete query would be far more efficient. Use the query builder to create a delete query and save it. Then instead of opening a recordset just .execute the querydef.
 

Users who are viewing this thread

Back
Top Bottom