DELETE MaxRecord

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table that data entry is entered into through a form. Once this data
has been entered an autonumber is assigned to each record with the latest
record entered having the highest number. I want to write a query that if the
person has entered the data wrongly that they can then delete the last
entered data.

I have got this far

DELETE * FROM tblData
WHERE tblData.ID = MAXVALUE
FROM tblData

Any help would be greatly recieved
 
Hi,


Since MAXVALUE is unknown, you can use DMAX( ..., ..., ... ) to find it:


DELETE *
FROM tableName
WHERE dataID= DMAX("dataID", "tableName")


You can also try:


DELETE *
FROM tableName
WHERE dataID=(SELECT MAX(dataID) FROM tableName)


which should be "updateable" in this case, too.


Note that nothing limit the "max", you can add a where clause (in DMAX or in
the sub-query), if required.



Hoping it may help,
Vanderghast, Access MVP
 
Back
Top