How can I delete all the records in a table?

pjustin1

Registered User.
Local time
Today, 23:13
Joined
Nov 9, 2001
Messages
15
Hi, I want to delete all the records in a table after sending these records to a report named as "MonthlyBalance" when I click a button. I written the following codes and I knew there is something wrong but I don't know where... can someone plse help me out with this? Here, I assume the field "BookTitle" will not contain "*" so all the records should be deleted...
Or is there a more correct way to delete all the records..?

Set rst = db.OpenRecordset("Select * From BalanceTable", dbOpenDynaset)
stDocName = "MonthlyBalance"
DoCmd.OpenReport stDocName, acPreview

wrk.BeginTrans
Do Until rst.EOF
If (rst!BookTitle <> "*") Then
rst.Delete
rst.Update
End If
rst.MoveNext
Loop
wrk.CommitTrans

Thanks!
 
A Delete Query is the ticket.
In the Access Help File, search on Delete Queries | Creating for more detailed information.
 
The following line will delete all records from the table.

db.Execute "DELETE * FROM BalanceTable"

HTH
wink.gif
 

Users who are viewing this thread

Back
Top Bottom