Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Last Record in a Table

Status
Not open for further replies.

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

 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top