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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| Private Sub Commande9_Click()
On Error GoTo Err_Commande9_Click
Dim echeance As Variant
Dim jours As Variant
Dim Datenormale As Variant
Dim dateecheance As Date
Dim dernjour As Integer
Datenormale = Date
'ouverture des formulaires nécessaires
DoCmd.OpenForm "Dialogue recherche contact", acNormal, "", "", , acNormal
DoCmd.OpenForm "CONTACTS", acNormal, "", "[code contact]=[Forms]![confirmationfacture]![code contact]", , acHidden
DoCmd.OpenForm "factureimmédiate", acNormal, "", "", , acNormal
'génération d'une nouvelle facture
DoCmd.GoToRecord acForm, "factureimmédiate", acNewRec
'détermination de l'échéance de la facture
Forms!factureimmédiate!édition = True
echeance = Forms!factureimmédiate![echeance]
'échéance fin de mois'
If Forms!factureimmédiate![jourecheance] = 31 Then
MsgBox "echeance fin de mois"
dernjour = Day(DateSerial(Year(Datenormale), Month(Datenormale) + echeance + 1, 0))
datecheance = CDate(dernjour & Format(DateAdd("m", echeance, Datenormale), "/mm/yyyy"))
MsgBox datecheance
Forms!factureimmédiate!dateecheance = datecheance
'Paiement à réception'
ElseIf (echeance < 1) Then
MsgBox "paiement à réception"
dateecheance = Format(Datenormale, "dd/mm/yyyy")
MsgBox datecheance
Forms!factureimmédiate!dateecheance = Date
Else
'jour échéance spécifique'
MsgBox "echeance spécifique"
jours = Forms!factureimmédiate![jourecheance]
datecheance = CDate(jours & Format(DateAdd("m", echeance, Datenormale), "/mm/yyyy"))
MsgBox datecheance
Forms!factureimmédiate!dateecheance = datecheance
End If
'Ajout du numéro de facture aux bons et de la coche facturé
DoCmd.OpenQuery "ajoutnumfacture", acNormal, acEdit
DoCmd.Close acForm, "factureimmédiate"
'copiage des bons vers la table bonfacture
DoCmd.OpenQuery "facturationdiffere", acNormal, acAdd
DoCmd.OpenQuery "archivagebon", acNormal, acAdd
DoCmd.OpenTable "bon", acNormal, acReadOnly
DoCmd.Close acForm, "CONTACTS"
DoCmd.OpenForm "Dialogue recherche contact", acNormal, "", "", , acHidden
DoCmd.OpenForm "CONTACTS", acNormal, "", "", , acHidden
DoCmd.OpenForm "factureimmédiate", acNormal, "", "", , acHidden
DoCmd.GoToRecord acForm, "factureimmédiate", acLast
DoCmd.OpenReport "factureimmediate", acPreview, "", ""
DoCmd.Close acForm, "factureimmédiate"
DoCmd.Close acForm, "Dialogue recherche contact"
DoCmd.Close acTable, "bon"
DoCmd.Close acForm, "CONTACTS"
DoCmd.Close acForm, "confirmationfacture"
DoCmd.Close acForm, "bonlisting"
DoCmd.OpenForm "bonlisting", acNormal, "", "", , acNormal
Exit_Commande9_Click:
Exit Sub |