Hi all, my database is based around vehicle maintenance etc, so my query looks if a vehicle has been inspected, and calculates from that date to the next based on a given number of weeks, this all works fine for reporting purposes. What I would like to do is also show the last known mileage whether inspected or not. The inspected field is a yes/no. so in the criteria of the inspected column I have a yes, but this of course limits the results for the report, is there a way to show the max of mileage and if inspected or not. This is my query.
SELECT tblmain.Unit, tblWorkdone.Unitid, Max(tblWorkdone.NewJobDate) AS MaxOfNewJobDate, tblWorkdone.Inspected, tblStatus.Status, tblCategory.Category, Max(IIf([Serviced]=-1,[tblworkdone]![mileagehours]+[mileageint],[tblworkdone].[mileagehours])) AS [Next Service]
FROM ((tblmain LEFT JOIN tblWorkdone ON tblmain.Unitid = tblWorkdone.Unitid) INNER JOIN tblStatus ON tblmain.StatusID = tblStatus.StatusID) INNER JOIN tblCategory ON tblmain.CategoryID = tblCategory.CategoryID
GROUP BY tblmain.Unit, tblWorkdone.Unitid, tblWorkdone.Inspected, tblStatus.Status, tblCategory.Category
HAVING (((tblWorkdone.Inspected)=Yes) AND ((tblStatus.Status)<>"sold" And (tblStatus.Status)<>"disposed" And (tblStatus.Status)<>"Yard Use Only" And (tblStatus.Status)<>"Stolen" And (tblStatus.Status)<>"Spares Only" And (tblStatus.Status)<>"Inactive"))
ORDER BY Max(tblWorkdone.NewJobDate) DESC;
Hope this makes sense please feel free to ask any questions.
Tony