Need help with an Access2007 query

Hi Experts,
I want to modify the query below, which I use in my Access2007 application.  I want the query to only return the latest test taken base on the DateTaken field.  So if a student has taken the same test three times, I only want the query to return one record (the latest record based on a Date field).  How can I do this?

SELECT * FROM TestsTaken WHERE [StudentID] = 100 AND [TestName] = 'WeeklyExam'


Thanks in advance,
mrotor
mainrotorAsked:
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.

unknown_routineCommented:
SELECT * FROM TestsTaken WHERE [StudentID] = 100 AND [TestName] = 'WeeklyExam'

And TestDate=(Select MAX(TestDate) from TestsTaken WHERE [StudentID] = 100 AND [TestName] = 'WeeklyExam')


In above I called your Date field TestDate
0

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
Rey Obrero (Capricorn1)Commented:
try

SELECT T.*
FROM  TestsTaken As T
Inner Join
(Select MAX(T2.TestDate) as MaxTestDate, T2.[StudentID], T2.[TestName] from TestsTaken as T2
  Where T2.[TestName] = 'WeeklyExam'
  Group By  T2.[StudentID], T2.[TestName]) As T3
ON T.[StudentID]=T3.[StudentID] And T.TestDate=T3.MaxTestDate
0
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
Microsoft Access

From novice to tech pro — start learning today.