Bonjour, je souhaite créer un formulaire de modification de ma base de données tout en ayant une rechercher automatique de mon numéro article car ils sont nombreux. Cependant, avec tous les tests possibles que j'ai fait, la modification ne s'effectue pas ou bien il rajoute une ligne. Pouvez-vous m'aider s'il vous plaît ? Voici mon code :
Je vous remercie par avance du temps consacré à ma demande Bonne journée à vous !

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
Private Sub btnAnnuler_Click()
    Unload Me
End Sub
 
 
Private Sub frmModif_Initialize()
 
    Dim modif As Integer
 
    If Not TxtNumeroArticle.Value = "" Then
 
    Sheets("plouagat").Select
    modif = ComboBox1.ListIndex + 2
 
     Cells(modif, 2) = TxtCodebarre.Value
     Cells(modif, 3) = TxtDescription.Value
     Cells(modif, 4) = TxtAutreDescription.Value
     Cells(modif, 5) = TxtUnite.Value
     Cells(modif, 6) = TxtSite.Value
     Cells(modif, 7) = TxtEmplacement.Value
     Cells(modif, 8) = TxtFamille.Value
     Cells(modif, 9) = TxtGroupe.Value
     Cells(modif, 10) = TxtSSFamille1.Value
     Cells(modif, 11) = TxtSSFamille2.Value
     Cells(modif, 12) = TxtCommentaire.Value
     Else
 
        MsgBox ("Modification effectuer")
 
    Exit Sub
 
    End If
 
        Unload frmModif
        frmModif.Show 0
 
End Sub
 
'Procédure permettant de mettre à jour la base
Private Sub btnValider_Click()
 
    If TxtNumeroArticle.Value = "" Then
    MsgBox "Veuillez renseigner le code article"
 
    Else
 
        Dim ligne As Integer
 
    Reponse = MsgBox("Désirez-vous sauvegarder les modifications ?", _
                vbQuestion + vbYesNo + vbDefaultButton1, "CONFIRMATION MODIFICATION")
    Worksheets("plouagat").Select
    ligne = Sheets("plouagat").Range("A456541").End(xlUp).Row + 1
 
    If Reponse = vbYes Then
 
       Else
     TxtNumeroArticle.Value = Cells(ligne, 1)
     TxtCodebarre.Value = Cells(ligne, 2)
     TxtDescription.Value = Cells(ligne, 3)
     TxtAutreDescription.Value = Cells(ligne, 4)
     TxtUnite.Value = Cells(ligne, 5)
     TxtSite.Value = Cells(ligne, 6)
     TxtEmplacement.Value = Cells(ligne, 7)
     TxtFamille.Value = Cells(ligne, 8)
     TxtGroupe.Value = Cells(ligne, 9)
     TxtSSFamille1.Value = Cells(ligne, 10)
     TxtSSFamille2.Value = Cells(ligne, 11)
     TxtCommentaire.Value = Cells(ligne, 12)
 
        MsgBox ("Modification effectuer")
 
     End If
        Unload Me
 
  End If
 
End Sub
Private Sub TxtNumeroArticle_Change()
    Dim F As Worksheet, rArt As Range
    Set F = Worksheets("plouagat")
    Set rArt = F.Range("A:A").Find(Me.TxtNumeroArticle.Value)
    If rArt Is Nothing Then
        MsgBox "Ce numéro d'article n'existe pas. Veuillez saisir un nouveau numéro", vbInformation + vbOKOnly, "Article non trouvé"
    Else
        With Me
            .TxtCodebarre = rArt.Offset(0, 1)
            .TxtDescription = rArt.Offset(0, 2)
            .TxtAutreDescription = rArt.Offset(0, 3)
            .TxtUnite = rArt.Offset(0, 4)
            .TxtSite = rArt.Offset(0, 5)
            .TxtEmplacement = rArt.Offset(0, 6)
            .TxtFamille = rArt.Offset(0, 7)
            .TxtGroupe = rArt.Offset(0, 8)
            .TxtSSFamille1 = rArt.Offset(0, 9)
            .TxtSSFamille2 = rArt.Offset(0, 10)
            .TxtCommentaire = rArt.Offset(0, 11)
        End With
    End If
    Set rArt = Nothing
    Set F = Nothing
End Sub