Newbie Last date question

S

stephent

Hi, I would appreciate some help please.
I have a query I am running via command button on a form. It uses fields
from two tables, the fields are Vehicle_ID and Mileage_In - this gives the
latest mileage on each vehicle as it was recorded after returning from hire.
As vehicles get used repeatedly I now want to get the query to show only the
latest/current Mileage_In.
I have added the Date field and now would like to know what criteria will
filter just the latest date please. Basic I know, but I would be grateful!
TIA
Steve
 
V

Van T. Dinh

Since the Mileage_In is always increasing (unless the odometer is reset
which is illegal in most countries), you can simply get the max using a
Query with SQL

SELECT T.Vehicle_ID, Max(T.Mileage_In) As MaxOfMileage_In
FROM YourTable As T
GROUP BY T.Vehicle_ID

If you want to base on the max date, see the techniques in The Access Web
article:

http://www.mvps.org/access/queries/qry0020.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top