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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
'******************************
'procédure permettant de
'Fermer mon formulaire
'******************************
Private Sub btnFermmer_Click()
Unload Me
End Sub
Private Sub btnChercher_Click()
Dim I As Long, nbLignes As Long
Dim Donnée As Worksheet
Dim Trouve As Boolean
Set Donnée = Sheets("Donnée")
nbLignes = Donnée.Cells(Rows.Count, "A").End(xlUp).Row
' Recherche les valeurs entrées dans txtCommentaire et txtContacte
For I = 1 To nbLignes
If LCase(Donnée.Range("C" & I)) = LCase(CMtxtRégime.Value) And LCase(Donnée.Range("D" & I)) = LCase(UserForm1.CMtxtRéférence.Value) Then 'vérifie les lettres de colonnes
Trouve = True
UserForm1.CMtxtDatedébut.Value = Donnée.Cells(I, 1).Value
UserForm1.CMCombocode.Value = Donnée.Cells(I, 2).Value
UserForm1.CMtxtRégime.Value = Donnée.Cells(I, 3).Value
UserForm1.CMtxtRéférence.Value = Donnée.Cells(I, 4).Value
UserForm1.CMtxtImportateur.Value = Donnée.Cells(I, 5).Value
UserForm1.CMtxtExportateur.Value = Donnée.Cells(I, 6).Value
UserForm1.CMtxtDésignation.Value = Donnée.Cells(I, 7).Value
UserForm1.CMcboTransitaire.Text = Donnée.Cells(I, 8).Value
UserForm1.CMcboEtat.Text = Donnée.Cells(I, 9).Value
UserForm1.CMtxtNb.Value = Donnée.Cells(I, 10).Value
UserForm1.CMtxtDatedépôt.Value = Donnée.Cells(I, 11).Value
UserForm1.CMtxtPoids.Value = Donnée.Cells(I, 12).Value
UserForm1.CMtxtValeur.Value = Donnée.Cells(I, 13).Value
UserForm1.CMtxtlValeurMad.Value = Donnée.Cells(I, 14).Value
UserForm1.CMtxtDateclôture.Value = Donnée.Cells(I, 15).Value
UserForm1.CMcboModetransport.Text = Donnée.Cells(I, 16).Value
Exit For
End If
Next
If Not Trouve Then
MsgBox "Aucune donnée correspondante trouvée"
End If
Set Donnée = Nothing
End Sub
'******************************
'Procédure permettant d'acéder
'a la Base de données
'******************************
Private Sub btnSource_Click()
Sheets("Donnée").Activate
Range("A1").Select
End Sub
Private Sub btnsupprimer_Click()
r = MsgBox("Voulez vous confirmer la suppression?", vbYesNo, "gestion des déclarations")
If r <> 16 Then Exit Sub
Selection.EntireRow.Delete
End Sub
Private Sub btnModifier_Click()
Set Donnée = Sheets("Donnée")
nbLignes = Donnée.Cells(Rows.Count, "A").End(xlUp).Row
For I = 1 To nbLignes
If LCase(Donnée.Range("C" & I)) = LCase(CMtxtRégime.Value) And LCase(Donnée.Range("D" & I)) = LCase(UserForm1.CMtxtRéférence.Value) Then 'vérifie les lettres de colonnes
Trouve = True
UserForm1.CMtxtDatedébut.Value = Donnée.Cells(I, 1).Value
Donnée.Cells(I, 2).Value = UserForm1.CMCombocode.Value
Donnée.Cells(I, 3).Value = UserForm1.CMtxtRégime.Value
Donnée.Cells(I, 4).Value = UserForm1.CMtxtRéférence.Value
Donnée.Cells(I, 5).Value = UserForm1.CMtxtImportateur.Value
Donnée.Cells(I, 6).Value = UserForm1.CMtxtExportateur.Value
Donnée.Cells(I, 7).Value = UserForm1.CMtxtDésignation.Value
Donnée.Cells(I, 8).Value = UserForm1.CMcboTransitaire.Text
Donnée.Cells(I, 9).Value = UserForm1.CMcboEtat.Text
Donnée.Cells(I, 10).Value = UserForm1.CMtxtNb.Value
Donnée.Cells(I, 11).Value = UserForm1.CMtxtDatedépôt.Value
Donnée.Cells(I, 12).Value = UserForm1.CMtxtPoids.Value
Donnée.Cells(I, 13).Value = UserForm1.CMtxtValeur.Value
Donnée.Cells(I, 14).Value = UserForm1.CMtxtlValeurMad.Value
Donnée.Cells(I, 15).Value = UserForm1.CMtxtDateclôture.Value
Donnée.Cells(I, 16).Value = UserForm1.CMcboModetransport.Text
Exit For
End If
Next
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub MultiPage1_Change()
End Sub
Private Sub UserForm_Initialize()
txtDatedébut.Value = Date
txtDatedépôt.Value = Date
End Sub
'Procédure permettant de réinitialiser tous
'les champs du formulaire page 1 & page 2
'***********************************************
Private Sub btnEffacer_Click()
Select Case Me.MultiPage1.Pages0
Case 1:
txtDatedébut = ""
Combocode = ""
txtRégime = ""
txtRéférence = ""
txtImportateur = ""
txtExportateur = ""
txtDésignation = ""
cboTransitaire = ""
cboEtat = ""
txtNb = ""
txtDatedépôt = ""
txtPoids = ""
txtValeur = ""
txtlValeurMad = ""
txtDateclôture = ""
cboModetransport = ""
Case 2:
CMtxtDatedébut = ""
CMCombocode = ""
CMtxtRégime = ""
CMtxtRéférence = ""
CMtxtImportateur = ""
CMtxtExportateur = ""
CMtxtDésignation = ""
CMcboTransitaire = ""
CMcboEtat = ""
CMtxtNb = ""
CMtxtDatedépôt = ""
CMtxtPoids = ""
CMtxtValeur = ""
CMtxtlValeurMad = ""
CMtxtDateclôture = ""
CMcboModetransport = ""
End Select
End Sub
'Procédure permettant de réinitialiser tous
'le bouton d'ajout d'enregistrement
'***********************************************
Private Sub txtDatedébut_Change()
If txtDatedébut <> "" Then
btnAjout.Enabled = True 'Activer le bouton
Else
btnAjout.Enabled = False 'Désactiver le bouton
End If
End Sub
'*********************************************
'Procédure permettant d'ajouter un nouvel enregistrement
'dans la base de données
'***********************************************
Private Sub btnAjout_Click()
I = Sheets("Donnée").Range("A665536").End(xlUp).Row
Sheets("Donnée").Range("A" & I + 1).Value = txtDatedébut
Sheets("Donnée").Range("B" & I + 1).Value = Combocode
Sheets("Donnée").Range("C" & I + 1).Value = txtRégime
Sheets("Donnée").Range("D" & I + 1).Value = txtRéférence
Sheets("Donnée").Range("E" & I + 1).Value = cboTransitaire
Sheets("Donnée").Range("F" & I + 1).Value = txtExportateur
Sheets("Donnée").Range("G" & I + 1).Value = txtImportateur
Sheets("Donnée").Range("H" & I + 1).Value = txtDésignation
Sheets("Donnée").Range("I" & I + 1).Value = txtNb
Sheets("Donnée").Range("J" & I + 1).Value = txtPoids
Sheets("Donnée").Range("K" & I + 1).Value = txtDatedépôt
Sheets("Donnée").Range("L" & I + 1).Value = txtValeur
Sheets("Donnée").Range("M" & I + 1).Value = txtlValeurMad
Sheets("Donnée").Range("N" & I + 1).Value = cboEtat
Sheets("Donnée").Range("O" & I + 1).Value = txtDateclôture
Sheets("Donnée").Range("P" & I + 1).Value = cboModetransport
End Sub |
Partager