Try this:
Code:
Private Sub UnitNumber_AfterUpdate()
On Error GoTo Err_Handler
Dim db As DAO.Database
Dim r As DAO.Recordset
Dim StrSql As String
Dim Item As String
Dim WheelPosition As String
Dim UnitNumber As Integer
Dim LFTreadDepth As Integer
Set db = CurrentDb
Item = "Brake Lining"
WheelPosition = "Right Front"
UnitNumber = Me.UnitNumber
StrSql = "SELECT main.measurement FROM Main "
StrSql = StrSql & " WHERE main.unitnumber = " & UnitNumber & " AND main.item = '" & Item & "' AND main.Wheel_position = '" & WheelPosition & "'"
StrSql = StrSql & " ORDER BY [YourDatefield] DESC "
Set r = db.OpenRecordset(StrSql)
If Not r.BOF And Not r.EOF Then
'do something with the measurement field value
Else
MsgBox "No measurement found for Unit " & UnitNumber & ", " & Item & " and " & WheelPosition
End If
' CurrentProject.Connection.Execute StrSql '<< only used for action queries, not select queries
Exit_Here:
'close recordset and clean up
StrSql.Close
Set StrSql = Nothing
Set db = Nothing
Err_Handler:
MsgBox Err.Description & " " & Err.Number & " - " & UnitNumber & ", " & Item & " and " & WheelPosition, vbExclamation, "Error"
Resume Exit_Here
End Sub
Change [YourDatefield] to the name of your date field.
The text fields didn't have required delimiters in the SQL string.
You didn't say what you wanted to do with the value if found........