Delete Duplicate Records with same value

I have an access database with the table (table1)  and fields (Name),(Date),(Time)etc...

I need VBA code that will delete duplicate records where count(Name) >1 Orderd by date, time

i.e. if two records have the same name i want to keep the newest record

ssql = "SELECT count(Name), Date, Time as Found" & _
"FROM table1" & _
"Group By  Name, Date, Time" & _
"Having count(Name) > 1"

I have the following select query but im struggling a bit as how to delete the duplicate record based on time and how to create a connection string between the code and my database



Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Add to table table one column ID autonumber(if you don't have one).Make copy of your table

Delete * from table1 where ID not in (select first(ID) from table1 Group By  Name, Date, Time)
Delete * from table1 where ID not in (select last(ID) from table1 Group By  Name, Date, Time)
May be last more changes
Delete * from table1 where ID not in (select last(ID) from table1 Group By  Name, Date, Time order by ID desc)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

I do believe question been answered
seanmorrisAuthor Commented:
Sorry for the delay in accepting this question.

Best Regards

No problem,good luck with your project
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.