'Attention les deux lignes suivantes doivent être impérativement placées en tout début de programme
'Début ***** Code de programmation de l'Userform C_RECAP_SUIVI_FACTURES *****
'***** Correspond au programme du FORMULAIRE à son ouverture *****
Option Explicit
Dim WithEvents CL As ComboBoxLiées
Dim LCou As Long ' Numéro de ligne en cours de MàJ. 0 ==> Création.
Dim VLgn() ' Valeurs de la ligne courante à charger ou décharger.
'***** Correspond au programme du FORMULAIRE à son ouverture *****
'Cet évènement est important car il permet de définir les propriétés des objets et les valeurs par défaut des variables, lors du lancement du Userform.
Private Sub UserForm_Initialize() 'à l'initialisation de l'userform
Set CL = New ComboBoxLiées
CL.Plage Sheets("SUIVI FACTURES").Rows(5)
CL.Add ComboBox1, "A"
CL.Add ComboBox2, "B"
CL.CorrespRequise = True
CL.Actualiser
End Sub
'**** Correspond au programme du bouton "QUITTER" *****
Private Sub BtnFermer_Click()
If BtnFermer.Caption = "EFFACER" Then
CL.Nettoyer: BtnFermer.Caption = "FERMER"
Else: Me.Hide: End If
End Sub
'***** Correspond au programme du bouton "INSERER DANS SUIVI FACTURES" *****
Private Sub CL_Change(ByVal Complet As Boolean, ByVal NbrLgn As Long)
If NbrLgn = 1 Then Exit Sub
LCou = 0
ReDim VLgn(5 To 5, 1 To 22)
GarnirChamps
Me.BtnValider.Caption = "INSERER DANS SUIVI FACTURES"
Me.BtnAnnuler.Caption = "Effacer"
End Sub
'***** Correspond au programme du bouton "MODIFIER" *****
Private Sub CL_BingoUn(ByVal Ligne As Long)
LCou = Ligne
VLgn = CL.PlgTablo.Rows(LCou).Resize(, 24).Value
GarnirChamps
Me.BtnValider.Caption = "Modifier"
Me.BtnAnnuler.Caption = "Effacer"
Private Sub GarnirChamps()
TextBox1 = VLgn(1, 3) ' date de la facture
TextBox2 = VLgn(1, 4) ' date d'échéance
TextBox3 = VLgn(1, 5) ' montant ttc
TextBox4 = VLgn(1, 6) ' nombre de jours dépassés
TextBox5 = VLgn(1, 7) ' majoration
TextBox6 = VLgn(1, 8) ' solde dû
TextBox7 = VLgn(1, 9) ' réglée
TextBox8 = VLgn(1, 10) ' date du règlement
TextBox9 = VLgn(1, 11) ' montant total payé
TextBox10 = VLgn(1, 12) ' majoration payée
TextBox11 = VLgn(1, 13) ' première relance
TextBox12 = VLgn(1, 14) ' deuxième relance
TextBox13 = VLgn(1, 15) ' troisième relance
TextBox14 = VLgn(1, 16) ' observation
TextBox15 = VLgn(1, 17) ' tva 5.5%
TextBox16 = VLgn(1, 18) ' tva 7%
TextBox17 = VLgn(1, 19) ' tva 10%
TextBox18 = VLgn(1, 20) ' tva 20%
TextBox19 = VLgn(1, 21) ' montant ht
TextBox20 = VLgn(1, 22) ' adresse
TextBox21 = VLgn(1, 23) ' code postal
TextBox22 = VLgn(1, 24) ' ville
End Sub
Private Sub BtnAnnuler_Click()
Select Case BtnAnnuler.Caption
Case "Annuler": GarnirChamps: BtnAnnuler.Caption = "Effacer"
Case "Effacer": CL.Nettoyer: BtnAnnuler.Caption = "Quitter"
Case "Quitter": Unload Me
End Select
End Sub
'***** Correspond au programme du bouton "VALIDER" *****
Private Sub BtnValider_Click()
Dim I&
If LCou = 0 Then
LCou = CL.PlgTablo.Rows.Count
CL.PlgTablo.Rows(LCou).Copy
CL.PlgTablo.Rows(LCou).Insert
Application.CutCopyMode = False
LCou = LCou + 1
For I = 1 To CL.Count ' Écrire les Text des ComboBox
VLgn(1, CL.Item(I).Col) = Trim$(CL.Item(I).CBx.Text)
Next I: End If
VLgn(1, 3) = TextBox1 ' date de la facture
VLgn(1, 4) = TextBox2 ' date d'échéance
VLgn(1, 5) = TextBox3 ' montant ttc
VLgn(1, 6) = TextBox4 ' nombre de jours dépassés
VLgn(1, 7) = TextBox5 ' majoration
VLgn(1, 8) = TextBox6 ' solde dû
VLgn(1, 9) = TextBox7 ' réglée
VLgn(1, 10) = TextBox8 ' date du règlement
VLgn(1, 11) = TextBox9 ' montant total payé
VLgn(1, 12) = TextBox10 ' majoration payée
VLgn(1, 13) = TextBox11 ' première relance
VLgn(1, 14) = TextBox12 ' deuxième relance
VLgn(1, 15) = TextBox13 ' troisième relance
VLgn(1, 16) = TextBox14 ' observation
VLgn(1, 17) = TextBox15 ' tva 5.5%
VLgn(1, 18) = TextBox16 ' tva 7%
VLgn(1, 19) = TextBox17 ' tva 10%
VLgn(1, 20) = TextBox18 ' tva 20%
VLgn(1, 21) = TextBox19 ' montant ht
VLgn(1, 22) = TextBox20 ' adresse
VLgn(1, 23) = TextBox21 ' code postal
VLgn(1, 24) = TextBox22 ' villeCL.PlgTablo.Rows(LCou).Resize(, 12).Value = VLgn
CL.Actualiser
End Sub
' --------------- N'autorise que la saisie de chiffres
Private Sub TextBox9_KeyPress(ByVal Touche As MSForms.ReturnInteger)
If InStr("0123456789", Chr(Touche)) = 0 Then Touche = 0: Beep
End Sub
Private Sub TextBox1_Change()
Dim Exemple As String
Dim ExDate As String
Exemple = TextBox1.Value
If ((Len(Exemple) > 5) And (Len(Exemple) < 8)) Then
Application.EnableEvents = False
ExDate = Mid(Exemple, 1, 2) & "/" & Mid(Exemple, 3, 2) & "/" & Mid(Exemple, 5)
TextBox1.Value = ExDate
Application.EnableEvents = True
End If
End Sub
'**** Correspond au programme croix dans l'userform *****
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
MsgBox "Vous ne pouvez pas utiliser la croix pour fermer ce formulaire." & vbLf & "Veuillez cliquer sur le bouton de commande 'Fermer'.", vbCritical
Cancel = True
End If
End Sub
'Fin ***** Code de programmation de l'Userform C_RECAP_SUIVI_FACTURES *****