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!
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!