-----Original Message-----
i have two tables, 'vehicles' and 'mileages'.
vehicles has lots of fields including 'reg', 'purchase
date', 'service due date' and 'service due mileage'.
the mileage table has 'reg'(linked to the reg in the
other table), 'date' and 'speedo reading'. this is info
is in a aub form of the main vehicles form. in the
footer of the sub form i have a calculated box giving the
max[speedo reading] which makes that the current
mileage. as you explained i have now got a current
mileage in my main form along side the 'service due
mileage'.i need to stipulate in a query that if the
current mileage gets to within 200 miles of the 'service
due mileage' then the record will be displayed. i used
to do it using dates and that was easy but now i need to
bring this info up based on the mileage instead. is it
possible to have a field in a table that would display
the max speedo reading or can that only be obtained from
a control in a form???
Hope this makes sense!! i really do appreciate all your
help
No, you DON'T need to use a Form to calculate a maximum! You can do it
directly in a Query, in a couple or three different ways!
A Totals query, grouping by reg and selecting Max ([speedo reading]),
will get you the maximum. Try
SELECT [vehicles].[reg], Max([speedo reading]), [Service due milage]
FROM [vehicles] INNER JOIN [milage]
ON [vehicles].[reg] = [milage].[reg]
GROUP BY [vehicles].[reg], [vehicles].[Service due milage]
HAVING [vehicle due milage] - Max([speedo reading]) < 200;
The DMax() function also lets you look up a maximum value.
.