1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Function ML(Matr As Long, Nature As String, debut As Date, fin As Date, fonction As Long, Pourcent As Long) As Variant
Dim totAbs As Long
Dim totMois As Long
Dim stockAbstype As Long
If debut = fin Then
totMois = 1
Else
totMois = SumDateDiff(Matr, Nature)
If Nature = 31 Then
If Pourcent = 80 Then
ML = totMois / 5
Else
Pourcent = 50
ML = totMois / 2
End If
stockAbstype = ML
If stockAbstype = 4 Then
ML = "Exhausted"
End If
End If
End If
End Function
Private Function SumDateDiff(Matr, Nature) As Long
Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("Select debut, fin From Decisions " & _
"Where Matr =" & Matr & " And Nature = '" & Nature & "'")
With rs
If Not (.EOF And .BOF) Then .MoveFirst
While Not .EOF
SumDateDiff = SumDateDiff + DateDiff("m", Nz(.Fields("debut"), 0), Nz(.Fields("fin"), 0))
.MoveNext
Wend
.Close
End With
Set rs = Nothing
End Function |
Partager