1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Function DiffAccident(strNomPersonne As String) As Integer
Dim db As DAO.Database
Set db = CurrentDb
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("SELECT * FROM [AT] WHERE NomPersonne = '" & strNomPersonne & "' ORDER BY DateDéclaration", dbOpenDynaset)
Dim DateDernierAccident As Date
rs.MoveLast 'pour aller au dernier accident
DateDernierAccident = rs!DateDéclaration.Value
DiffAccident = DateDiff("d", DateDernierAccident, Date) 'différence par rapport à aujourd'hui.
End Function |
Partager