Hello all !

Petite problématique du jour :

J'ai un fichier de base de données Excel, sur lequel je réalise mes entrées grâce à un premier UserForm.
Cette base de données est vivante et est amenée à être modifiée régulièrement.

J'ai donc créé un deuxième userForm pour modifier les entrées de la base de données.
Ce UserForm de modification va chercher par le biais d'une ComboBox la référence d'un produit, et toutes les informations de la base de donnée liées à cette référence, sont entrées dans les champs correspondants de mon UserForm de modification.

Les images valent mieux que les mots :

Nom : Untitled.jpg
Affichages : 1160
Taille : 251,4 Ko

Pour informations, les boutons "Ajouter lien" permettent d'ajouter des liens hypertexte.

Donc le formulaire "Modifications" me permet de modifier mes entrées.

MAIS !...

Tout fonctionne comme je le souhaite, sauf le bouton "ANNULER".

Je souhaiterais pour ce bouton "ANNULER" du formulaire de modifications, que lorsque je clique dessus, il annule toutes les modifications, toutes les choses changées dans le formulaire de modifications, pour revenir à l'état original (avant d'avoir lancer le formulaire "Modifier" et d'avoir fait des modifications.

Pour les intéressés, voilà mon code pour le UserForm de modification :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Option Explicit
 
Dim Ws As Worksheet
 
 
'Permet de déverouiller la touche valider
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Me.CommandButton3.Enabled = True
Else
Me.CommandButton3.Enabled = False
End If
 
 
End Sub
 
Private Sub UserForm_Initialize()
Dim J As Long
Dim I As Integer
 
'Initialise le userform
Set Ws = Sheets("Bergstik")
 
 
With Me.ComboBox1
For J = 8 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
 
 
 
End Sub
 
 
 
 
Private Sub ComboBox1_Change()
 
'Permet de retrouver les données associées aux champs
 
Dim Ligne As Long
Dim I As Integer
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 8
 
If Ws.Cells(Ligne, "E") = "OUI" Then
OUI1.Value = True
Else
NON1.Value = True
End If
 
If Ws.Cells(Ligne, "G") = "OUI" Then
OUI2.Value = True
Else
NON2.Value = True
End If
 
If Ws.Cells(Ligne, "N") = "OUI" Then
OUI3.Value = True
Else
NON3.Value = True
End If
 
Nom_Lien.Text = Ws.Cells(Ligne, "F")
Exp.Text = Ws.Cells(Ligne, "H")
WHISKERS.Text = Ws.Cells(Ligne, "I")
UL.Text = Ws.Cells(Ligne, "J")
MSL.Text = Ws.Cells(Ligne, "K")
QUALIF_P.Text = Ws.Cells(Ligne, "L")
SPEC.Text = Ws.Cells(Ligne, "M")
 
End Sub
 
 
Private Sub CommandButton4_Click()
 
'Bouton annuler que je souhaite configurer
Modif_Bergstik.Hide
 
End Sub
 
Private Sub ADD1_Click()
 
 
    'ADD1 = Bouton "Ajouter Lien"
    Range("F8").Select
    Application.Dialogs(xlDialogInsertHyperlink).Show
    'Nom_Lien = textbox associée
    Nom_Lien.Text = Range("F8")
    DoEvents
 
End Sub
 
Private Sub ADD2_Click()
'ADD2 = Bouton "Ajouter Lien"
    Range("I8").Select
    Application.Dialogs(xlDialogInsertHyperlink).Show
    'WHISKERS = textbox associée
    WHISKERS.Text = Range("I8")
    DoEvents
End Sub
 
Private Sub ADD3_Click()
'ADD3 = Bouton "Ajouter Lien"
    Range("J8").Select
    Application.Dialogs(xlDialogInsertHyperlink).Show
    'UL = textbox associée
    UL.Text = Range("J8")
    DoEvents
End Sub
 
Private Sub ADD4_Click()
'ADD4 = Bouton "Ajouter Lien"
    Range("K8").Select
    Application.Dialogs(xlDialogInsertHyperlink).Show
    'MSL = textbox associée
    MSL.Text = Range("K8")
    DoEvents
End Sub
 
Private Sub ADD5_Click()
'ADD5 = Bouton "Ajouter Lien"
    Range("L8").Select
    Application.Dialogs(xlDialogInsertHyperlink).Show
    'QUALIF_P = textbox associée
    QUALIF_P.Text = Range("L8")
    DoEvents
End Sub
 
Private Sub ADD6_Click()
'ADD6 = Bouton "Ajouter Lien"
    Range("M8").Select
    Application.Dialogs(xlDialogInsertHyperlink).Show
    'SPEC.Text = textbox associée
    SPEC.Text = Range("M8")
    DoEvents
End Sub


Et le code qui initialise le userForm de modifications :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Private Sub Modif_Saisie_Click()
 
With Modif_Bergstik
 
    .ComboBox1.Text = ""
    .CheckBox1.Value = False
    .OUI1.Value = False
    .OUI2.Value = False
    .OUI3.Value = False
    .NON1.Value = False
    .NON2.Value = False
    .NON3.Value = False
    .Nom_Lien.Text = ""
    .Nom_Lien.Enabled = False
    .Exp.Text = ""
    .WHISKERS.Text = ""
    .WHISKERS.Enabled = False
    .UL.Text = ""
    .UL.Enabled = False
    .MSL.Text = ""
    .MSL.Enabled = False
    .QUALIF_P.Text = ""
    .QUALIF_P.Enabled = False
    .SPEC.Text = ""
    .SPEC.Enabled = False
    .CommandButton3.Enabled = False
 
 
End With
 
 
Modif_Bergstik.Show
 
End Sub
Voilà voilou, je vous remercie par avance pour votre aide,

Cordialement
JFA