Dec 12, 2002 #1 nickg96 MIS Jul 12, 2002 10 0 0 US Hi, I'm using MS Access 2000. Can someone please give me the VBA Code to Delete the Last Record in a Table? Thanks for your help, Nick
Hi, I'm using MS Access 2000. Can someone please give me the VBA Code to Delete the Last Record in a Table? Thanks for your help, Nick
Dec 13, 2002 #2 origapizni Programmer Aug 2, 2001 29 0 0 US This should work: Sub test_delete() Set db = CurrentDb() strRstName = "TestTable" 'your table name goes here Set rst = db.OpenRecordset(strRstName) With rst If .RecordCount > 0 Then .MoveLast .Delete End If End With rst.Close Set rst = Nothing Set db = Nothing End Sub Upvote 0 Downvote
This should work: Sub test_delete() Set db = CurrentDb() strRstName = "TestTable" 'your table name goes here Set rst = db.OpenRecordset(strRstName) With rst If .RecordCount > 0 Then .MoveLast .Delete End If End With rst.Close Set rst = Nothing Set db = Nothing End Sub