1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub Echéance_Click()
Select Case Nz(Me.Cond_règlt, 0)
Case "02", "021", "041"
Me.Echéance = DateEchéance(Me.date_facture, False)
Case "CO", "03", "04"
Me.Echéance = DateEchéance(Me.date_facture, True)
Case Else
Me.Echéance = Me.date_facture
End Select
End Sub
Private Function DateEchéance(ByVal DateRef As Date, ByVal BillDate As Boolean) As Date
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
intYear = IIf(Month(DateRef) = 12, Year(DateRef) + 1, Year(DateRef))
intMonth = IIf(Month(DateRef) = 12, 1, Month(DateRef) + 1)
intDay = IIf(Month(DateRef) = 12, 31, Day(DateSerial(Year(DateRef), Month(DateRef) + 2, 1) - 1))
If BillDate Then
DateEchéance = DateRef
Else
DateEchéance = CDate(DateSerial(intYear, intMonth, intDay))
End If
End Function |
Partager