Following code is tested:
I did not create a table C, instead, I add a field TimeEnd in tableB.
Code:
Public Function getTimeEnd()
'add a field timeEnd to tableB, the code will put end time in it
'if no score =1, timeEnd is 0
'ID,time, timeEnd are number fields.
'no matter if time is not consequent
Dim rsA As DAO.Recordset, rsB As DAO.Recordset
Dim curTime As Long 'max time with score 1
Set rsA = CurrentDb.OpenRecordset("select * from tableA order by id,[time]")
Set rsB = CurrentDb.OpenRecordset("select * from tableB order by id,[time]")
Do While Not rsB.EOF
curTime = rsB![Time]
Do
rsA.FindFirst "ID=" & rsB!ID & " and [time]=" & curTime & " and [score]=1"
If rsA.NoMatch Then
rsB.Edit
rsB![timeEnd] = IIf(curTime = rsB![Time], 0, curTime - 1)
rsB.Update
End If
curTime = curTime + 1
Loop While Not rsA.NoMatch
rsB.MoveNext
Loop
Set rsA = Nothing
Set rsB = Nothing
End Function