How do i delete last record in table? (1 Viewer)

hardrock

Registered User.
Local time
Today, 15:36
Joined
Apr 5, 2007
Messages
166
Hi all, whats the simplest way to delete the last record in a table? based on
DoCmd.RunSQL "DELETE * FROM

Trying to use a button to do the above

Cheers
 
Depends on what is the last record.

The last one added by date? the last one alphabetically? the latest ID number?

Col
 
re:

Hi Colin, Its basically a shopping cart, with goods added to the cart table when the 'add to cart' button is pressed. I now want to add a 'delete from cart' button so it deletes the last (bottom) record in table. I simply want to select last record and delete. No other parameters needed. Cheers
 
This might work for ya
Code:
    DoCmd.GoToRecord , , acLast
    docmd.RunCommand acCmdDeleteRecord
 
If the person selects "Delete Item", I would then have the cart contents shown in a continuous form, then get the person to select the item, then have an "are you sure?" yes / no MessageBox.

To rely on the correct item being the last one in the table may be suspect.

Col
 
re:

Col,

DoCmd.GoToRecord , , acLast
docmd.RunCommand acCmdDeleteRecord

How do i point to the table i want to delete from with the above? Cheers
 

Users who are viewing this thread

Back
Top Bottom