Problème de code VBA pour modification d'un formulaire

Bonjour à tous et merci d'avance pour l'aide futur.

Voilà, j'ai suivi un tuto pour la création d'un formulaire avec les boutons/fonctions:

  • nouveau client
  • modifier client
  • quitter.
Cependant le code pour la "modification client" ne fonctionne pas.

J'aimerais qu'une fois que la fiche se pré-remplit on puisse faire les modifications et qu'elle remplace les anciennes données dans ma base.

Merci d'avance

13projet-act.xlsm (25.23 Ko)

Bonjour,

Remplace CommandButton2_Click par ce code-ci.

 'Pour le bouton Modifier
Private Sub CommandButton2_Click()
Dim no_ligne As Integer

If MsgBox("Confirmez-vous la modification de ce contact ?", vbYesNo, "Demande de confirmation de modification") = vbYes Then
    no_ligne = ComboBox1.ListIndex + 2
    With Worksheets("Clients")
        .Cells(no_ligne, 1) = ComboBox1.Value
        .Cells(no_ligne, 2) = ComboBox2.Value
        .Cells(no_ligne, 3) = TextBox1
        .Cells(no_ligne, 4) = TextBox2
        .Cells(no_ligne, 5) = TextBox3
        .Cells(no_ligne, 6) = TextBox4
        .Cells(no_ligne, 7) = TextBox5
        .Cells(no_ligne, 8) = TextBox6
        .Cells(no_ligne, 9) = TextBox7
        .Cells(no_ligne, 10) = TextBox8
        .Cells(no_ligne, 11) = TextBox9
        .Cells(no_ligne, 12) = TextBox10
        .Cells(no_ligne, 13) = TextBox11
        .Cells(no_ligne, 14) = TextBox12
        .Cells(no_ligne, 15) = TextBox13
        .Cells(no_ligne, 16) = TextBox14
        .Cells(no_ligne, 17) = TextBox15
        .Cells(no_ligne, 18) = TextBox16
        .Cells(no_ligne, 19) = TextBox17
        .Cells(no_ligne, 20) = TextBox18
        .Cells(no_ligne, 21) = TextBox19
    End With
 End If
 End Sub

ric

Merci Ric pour le coup de main

ça fonctionne

merci beaucoup

Rechercher des sujets similaires à "probleme code vba modification formulaire"