MS Access returns different results each time

Hello,
I am puzzled.
This query:

SELECT DISTINCTROW Last(dbo_INVENTORY_TRANS.TRANSACTION_DATE) AS LastOfTRANSACTION_DATE, dbo_INVENTORY_TRANS.PART_ID
FROM dbo_INVENTORY_TRANS
GROUP BY dbo_INVENTORY_TRANS.PART_ID
HAVING (((Last(dbo_INVENTORY_TRANS.TRANSACTION_DATE))>#12/31/2012#) AND ((dbo_INVENTORY_TRANS.PART_ID) Is Not Null))
ORDER BY Last(dbo_INVENTORY_TRANS.TRANSACTION_DATE) DESC , dbo_INVENTORY_TRANS.PART_ID;

gives me different results each time I click Run.
The database is linked using ODBC to our ERP database. Nobody is logged in to the ERP, so no transactions are going on.
Difference between each time can come to almost thousand records.

What am I doing wrong?

Microsoft Access 2013. SQL Server 2007.
MezczyznaAsked:
Who is Participating?
 
Anders Ebro (Microsoft MVP)Connect With a Mentor Microsoft DeveloperCommented:
You should use Max instead of last.
0
 
ste5anSenior DeveloperCommented:
What do you want to achieve y using LAST()? Do you run it in Access or SQL Server?
0
 
MezczyznaAuthor Commented:
I think I tried, but I will again.
Thank you.
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
MezczyznaAuthor Commented:
I want the most recent transaction record on a part.
0
 
MezczyznaAuthor Commented:
Max gives me the same number of records each time.
If max is the solution to display the most recent record for inventory transaction, this is the solution.

Thank you.
0
 
MezczyznaAuthor Commented:
Thank you, max solved the issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.