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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| Private Sub Cmd_Validation_Click()
'Valider les données du formulaire
Dim Ctrl As Control
Dim r As Integer
Dim Derligne As Integer
Dim Rep As Integer
'Coloration des Labels en rouge
Label_Km.ForeColor = RGB(0, 0, 0)
Label_Litres.ForeColor = RGB(0, 0, 0)
Label_Montant.ForeColor = RGB(0, 0, 0)
Label_Agence.ForeColor = RGB(0, 0, 0)
Label_Model.ForeColor = RGB(0, 0, 0)
Label_Carb.ForeColor = RGB(0, 0, 0)
Label_Obj.ForeColor = RGB(0, 0, 0)
Label_Immat.ForeColor = RGB(0, 0, 0)
Label_Refact.ForeColor = RGB(0, 0, 0)
Label_Remark.ForeColor = RGB(0, 0, 0)
'Contrôles de contenu
If TextBox4.Value = "" Then 'SI pas de "nom" ...
Label_Km.ForeColor = RGB(255, 0, 0) 'Label "nom" en rouge
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf TextBox5.Value = "" Then
Label_Litres.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf TextBox6.Value = "" Then
Label_Montant.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf ComboBox3.Value = "" Then
Label_Agence.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf ComboBox4.Value = "" Then
Label_Model.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf ComboBox5.Value = "" Then
Label_Immat.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf ComboBox6.Value = "" Then
Label_Carb.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf ComboBox7.Value = "" Then
Label_Obj.ForeColor = RGB(255, 0, 0)
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
ElseIf (ComboBox7.Value = "TATA" Or ComboBox7.Value = "TOTO") Then
If TextBox8 = "" Or TextBox9 = "" Then
If TextBox8 = "" Then
Label_Remark.ForeColor = RGB(255, 0, 0)
End If
If TextBox9 = "" Then
Label_Refact.ForeColor = RGB(255, 0, 0)
End If
MsgBox (" Données manquantes à compléter !"), vbOK + vbExclamation, "SAISIE INCOMPLETE !"
Exit Sub
End If
End If
With Feuil1
Range("B2") = ComboBox2.Text
Derligne = .Range("A65536").End(xlUp).Row + 1
For Each Ctrl In USF_Saisie.Controls
r = Val(Ctrl.Tag)
If r > 0 Then Cells(Derligne, r) = TrouveType(Ctrl)
Next
End With
'Initialise le formulaire
Unload Me
USF_Saisie.Show
'End If
End Sub |
Partager