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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting records in a query...after record #5?

Status
Not open for further replies.

3Mark3

Technical User
Joined
Nov 30, 2005
Messages
48
Location
US
Hello all...I have this excel table that I have linked to my access database. I want to run a query that will delete all records after record number 5 (the 5th record). Is it possible to do this? I tried googling it and checking my books, but I can't seem to find anything.

Any help suggestion would be greatly appreciated.
 
Is there some field that identifies how to sort the records to get the top 5? Let's assume there's one called ID, then maybe a query something like:
Code:
DELETE * FROM ExcelTable WHERE ID NOT IN 
(SELECT TOP 5 ID 
FROM ExcelTable)

 
3Mark3,

Is the database really linked to an excel sheet? and do you really want to delete the rows in the excel sheet?

Or, do you want to only use the first five records in your database?

If it's the second, you could run a make table query and limit the results to the top 5.

Could you explain more clearly which it is you're after?

John




When Galileo theorized that Aristotle's view of the Universe contained errors, he was labeled a fool.
It wasn't until he proved it that he was called dangerous.
[wink]
 
Thanks all for your replies. Well I don't know why I didn't think of this before..but you can't delete from linked excel sheets? That's unfortunate. As soon as I try to delete data, it gives me this error:

Deleting data in a linked table is not supported by this ISAM.

So I guess I'm out of luck for this process. That's fine. Thanks anyway for replying!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top