Hello,
How can store the total of "DateDiff('m', [debut], [fin])" of a [Nature] by [Matr].
.
I have a table with fields debut, fin, Matr, Nature.
Matr Nature Debut fin Calculation (DateDiff('m', [debut], [fin])")
3478 Holiday 1/1/2017 5/1/2017 5 days
3478 Holiday 1/4/2017 3/4/2017 3 days
3478 Seek 1/5/2017 1/5/2017 1 days
What i will have :
Matr Nature ML
3478 Holidays 8
3478 Seek 1
Code:
Function ML(Matr As Long, Nature As String, debut As Date, fin As Date, fonction As Long) As String
Dim totAbs As Long
Dim totMois As Integer
totMois = Nz(DateDiff("m", [debut], [fin]))
totAbs = DSum("DateDiff('m', [debut], [fin])", "Decisions", "'[Matr]= ' & 'Matr' And '[Nature]= ' & 'Nature'")
If fonction = 1210 Or fonction = 1101 Then
ML = totMois
Else
ML = totAbs
End If
End Function