Probleme sur bouton modifier "enregistrement donnee"
bonjour
je me permet de vous solliciter car j'ai un probleme avec mon bouton modifier ddans mon userform
sur mon tableau recap un bouton modifier ouvre un userform ,je fait le rappel de la fiche a modifier avec mon combobx 5
l'enregistrement des modification ce fait bien mais dnas la fiche correspondante les donnee ne s'enregistre pas cela me mets une erreur
j'ai besoin de votre aide ci dessous mon code et mon fichier
[code]'APPELE DES DONNEE'
Private Sub Combobox5_Change()
Dim Ligne As Integer
With ThisWorkbook.Sheets("Recap")
Ligne = .Columns("B").Find(Me.ComboBox5.Value, .Range("b10"), xlValues).Row
Me.TextBoxobjet.Value = .Cells(Ligne, "C") 'colone c'
Me.ComboBox4.Value = .Cells(Ligne, "y") 'colone y'
Me.TextBoxfiche.Value = .Cells(Ligne, "Z") 'colone Z'
Me.TextBoxdate.Value = .Cells(Ligne, "AA") 'colone AA'
Me.TextBoximputation.Value = .Cells(Ligne, "AB") 'colone AB'
Me.TextBoxlocalisation.Value = .Cells(Ligne, "AC") 'colone Ac'
Me.ComboBox1.Value = .Cells(Ligne, "AD") 'colone AD'
Me.TextBoxannée.Value = .Cells(Ligne, "AE") 'colone AE'
Me.CheckBox1.Value = .Cells(Ligne, "AF") 'colone AF'
Me.CheckBox2.Value = .Cells(Ligne, "AG") 'colone ag'
Me.CheckBox3.Value = .Cells(Ligne, "AH") 'colone aH'
Me.TextBoxconstat.Value = .Cells(Ligne, "AI") 'colone AI'
Me.TextBoxrisque.Value = .Cells(Ligne, "AJ") 'colone AJ'
Me.TextBoxorigine.Value = .Cells(Ligne, "AK") 'colone AK'
Me.TextBoxconservatoires.Value = .Cells(Ligne, "AL") 'colone AL'
Me.TextBoxtravaux.Value = .Cells(Ligne, "AM") 'colone AM'
Me.TextBoxobservation.Value = .Cells(Ligne, "AN") 'colone AN'
Me.TextBoxconstructeur.Value = .Cells(Ligne, "AO") 'colone AO'
Me.TextBoxdureevie1.Value = .Cells(Ligne, "AP") 'colone AP'
Me.TextBoxdureevie2.Value = .Cells(Ligne, "AQ") 'colone AQ'
Me.TextBoximage.Value = .Cells(Ligne, "AR") 'colone AR'
End With
End Sub
Private Sub CommandButton2_Click()
Dim Ligne As Integer
With ThisWorkbook.Sheets("Recap")
Ligne = .Columns("B").Find(Me.ComboBox5.Value, .Range("b10"), xlValues).Row
.Range("C" & Ligne).Value = TextBoxobjet
.Range("Y" & Ligne).Value = ComboBox4
.Range("Z" & Ligne).Value = TextBoxfiche
.Range("AA" & Ligne).Value = CDate(TextBoxdate)
.Range("AB" & Ligne).Value = TextBoximputation
.Range("AC" & Ligne).Value = TextBoxlocalisation
.Range("AD" & Ligne).Value = ComboBox1
.Range("D" & Ligne).Value = ComboBox1
.Range("AE" & Ligne).Value = TextBoxannée
.Range("AF" & Ligne).Value = CheckBox1
.Range("AG" & Ligne).Value = CheckBox2
.Range("AH" & Ligne).Value = CheckBox3
.Range("AI" & Ligne).Value = TextBoxconstat
.Range("AJ" & Ligne).Value = TextBoxrisque
.Range("AK" & Ligne).Value = TextBoxorigine
.Range("AL" & Ligne).Value = TextBoxconservatoires
.Range("AM" & Ligne).Value = TextBoxtravaux
.Range("AN" & Ligne).Value = TextBoxobservation
.Range("AO" & Ligne).Value = TextBoxconstructeur
.Range("AP" & Ligne).Value = TextBoxdureevie1
.Range("AQ" & Ligne).Value = TextBoxdureevie2
.Range("AR" & Ligne).Value = TextBoximage
End With
.Name = Worksheets("RECAP").Range("B" & Ligne)
.Range("B3") = TextBoxobjet
.Range("A6") = TextBoxfiche
.Range("B6") = TextBoxdate
.Range("C6") = TextBoximputation
.Range("D6") = TextBoxlocalisation
.Range("E6") = ComboBox1
.Range("F6") = TextBoxannée
.Range("G6") = ComboBox4
.Range("A9") = TextBoxconstat
.Range("E11") = CheckBox1
.Range("E12") = CheckBox2
.Range("E13") = CheckBox3
.Range("A16") = TextBoxrisque
.Range("A21") = TextBoxorigine
.Range("A26") = TextBoxconservatoires
.Range("A30") = TextBoxtravaux
.Range("A35") = TextBoxobservation
.Range("H15") = TextBoxconstructeur
.Range("K17") = TextBoxdureevie1
.Range("K18") = TextBoxdureevie2
.Range("H20") = TextBoximage
End With
Unload UserForm3
End Sub
Private Sub Textboxdate_Change()
'Code permettant de mettre une date au format 00/00/0000 dans une textbox
Dim valeur As Byte
TextBoxdate.MaxLength = 10 'nb caractères maxi autorisé dans le textbox
valeur = Len(TextBoxdate)
If valeur = 2 Or valeur = 5 Then TextBoxdate = TextBoxdate & "/"
End Sub
de plus dans mon userform 1 l'insertion de mon image ne se fait pas cela mets que du texte
merci de votre aide
Bonjour Bredeche,
Tu peux changer ton code par celui ci-dessous :
'APPELE DES DONNEE'
Private Sub Combobox5_Change()
Dim r As Range
With ThisWorkbook.Sheets("Recap")
Set r = .Columns(2).Find(Me.ComboBox5.Value)
Me.TextBoxobjet = .Cells(r.Row, "C") 'colone c'
Me.ComboBox4.Value = .Cells(r.Row, "y") 'colone y'
Me.TextBoxfiche.Value = .Cells(r.Row, "Z") 'colone Z'
Me.TextBoxdate.Value = .Cells(r.Row, "AA") 'colone AA'
Me.TextBoximputation.Value = .Cells(r.Row, "AB") 'colone AB'
Me.TextBoxlocalisation.Value = .Cells(r.Row, "AC") 'colone Ac'
Me.ComboBox1.Value = .Cells(r.Row, "AD") 'colone AD'
Me.TextBoxannée.Value = .Cells(r.Row, "AE") 'colone AE'
Me.CheckBox1.Value = .Cells(r.Row, "AF") 'colone AF'
Me.CheckBox2.Value = .Cells(r.Row, "AG") 'colone ag'
Me.CheckBox3.Value = .Cells(r.Row, "AH") 'colone aH'
Me.TextBoxconstat.Value = .Cells(r.Row, "AI") 'colone AI'
Me.TextBoxrisque.Value = .Cells(r.Row, "AJ") 'colone AJ'
Me.TextBoxorigine.Value = .Cells(r.Row, "AK") 'colone AK'
Me.TextBoxconservatoires.Value = .Cells(r.Row, "AL") 'colone AL'
Me.TextBoxtravaux.Value = .Cells(r.Row, "AM") 'colone AM'
Me.TextBoxobservation.Value = .Cells(r.Row, "AN") 'colone AN'
Me.TextBoxconstructeur.Value = .Cells(r.Row, "AO") 'colone AO'
Me.TextBoxdureevie1.Value = .Cells(r.Row, "AP") 'colone AP'
Me.TextBoxdureevie2.Value = .Cells(r.Row, "AQ") 'colone AQ'
Me.TextBoximage.Value = .Cells(r.Row, "AR") 'colone AR'
End With
End Sub
A dispo si tu as des questions
Bonjour Bredeche,
Tu peux changer ton code par celui ci-dessous :
'APPELE DES DONNEE' Private Sub Combobox5_Change() Dim r As Range With ThisWorkbook.Sheets("Recap") Set r = .Columns(2).Find(Me.ComboBox5.Value) Me.TextBoxobjet = .Cells(r.Row, "C") 'colone c' Me.ComboBox4.Value = .Cells(r.Row, "y") 'colone y' Me.TextBoxfiche.Value = .Cells(r.Row, "Z") 'colone Z' Me.TextBoxdate.Value = .Cells(r.Row, "AA") 'colone AA' Me.TextBoximputation.Value = .Cells(r.Row, "AB") 'colone AB' Me.TextBoxlocalisation.Value = .Cells(r.Row, "AC") 'colone Ac' Me.ComboBox1.Value = .Cells(r.Row, "AD") 'colone AD' Me.TextBoxannée.Value = .Cells(r.Row, "AE") 'colone AE' Me.CheckBox1.Value = .Cells(r.Row, "AF") 'colone AF' Me.CheckBox2.Value = .Cells(r.Row, "AG") 'colone ag' Me.CheckBox3.Value = .Cells(r.Row, "AH") 'colone aH' Me.TextBoxconstat.Value = .Cells(r.Row, "AI") 'colone AI' Me.TextBoxrisque.Value = .Cells(r.Row, "AJ") 'colone AJ' Me.TextBoxorigine.Value = .Cells(r.Row, "AK") 'colone AK' Me.TextBoxconservatoires.Value = .Cells(r.Row, "AL") 'colone AL' Me.TextBoxtravaux.Value = .Cells(r.Row, "AM") 'colone AM' Me.TextBoxobservation.Value = .Cells(r.Row, "AN") 'colone AN' Me.TextBoxconstructeur.Value = .Cells(r.Row, "AO") 'colone AO' Me.TextBoxdureevie1.Value = .Cells(r.Row, "AP") 'colone AP' Me.TextBoxdureevie2.Value = .Cells(r.Row, "AQ") 'colone AQ' Me.TextBoximage.Value = .Cells(r.Row, "AR") 'colone AR' End With End Sub
A dispo si tu as des questions
Merci mais cela ne modifie en rien la fiche
Merci mais cela ne modifie en rien la fiche
Quand tu dit "la fiche" tu entend par là l'Userform ?
Que les données de la ligne correspondant viennent ce mettre correctement dans ton UserForm non ?
Si ce n'est pas sa, merci de réexpliquer ton problème.
Cdt
Alors je me réexplique lorsque je réalise une nouvelle fiche les éléments s' incrémente sur ligne dans le tableau et cela cree une fiche via une trame
ensuite si je veaux modifier une fiche
j'appelle la macro "modifier" sur le tableau "recap" je rappelle la fiche et la ligne désiré via le combobox 5 dans mon userform
et je modifie les éléments et a cela je réécrit sur la ligne choisis et je modifie sur la fiche choisie
mon code précédemment posté arrive a bien modifier mon tableau mais pas ma fiche selectionné
merci de ton aide
cordialement
Re-
Merci pour ces précisions.
Essaye de remplacer le code du CommandButton2 par celui-ci :
Private Sub CommandButton2_Click()
Dim Ligne As Integer, Verif As Boolean
With ThisWorkbook.Sheets("Recap")
Ligne = .Columns("B").Find(Me.ComboBox5.Value, .Range("b10"), xlValues).Row
.Range("C" & Ligne).Value = TextBoxobjet
.Range("Y" & Ligne).Value = ComboBox4
.Range("Z" & Ligne).Value = TextBoxfiche
If TextBoxdate <> "" Then .Range("AA" & Ligne).Value = CDate(TextBoxdate)
.Range("AB" & Ligne).Value = TextBoximputation
.Range("AC" & Ligne).Value = TextBoxlocalisation
.Range("AD" & Ligne).Value = ComboBox1
.Range("D" & Ligne).Value = ComboBox1
.Range("AE" & Ligne).Value = TextBoxannée
.Range("AF" & Ligne).Value = CheckBox1
.Range("AG" & Ligne).Value = CheckBox2
.Range("AH" & Ligne).Value = CheckBox3
.Range("AI" & Ligne).Value = TextBoxconstat
.Range("AJ" & Ligne).Value = TextBoxrisque
.Range("AK" & Ligne).Value = TextBoxorigine
.Range("AL" & Ligne).Value = TextBoxconservatoires
.Range("AM" & Ligne).Value = TextBoxtravaux
.Range("AN" & Ligne).Value = TextBoxobservation
.Range("AO" & Ligne).Value = TextBoxconstructeur
.Range("AP" & Ligne).Value = TextBoxdureevie1
.Range("AQ" & Ligne).Value = TextBoxdureevie2
.Range("AR" & Ligne).Value = TextBoximage
End With
For x = 1 To Worksheets.Count
If Sheets(x).Name = Me.ComboBox5.Value Then Sheets(x).Select: Verif = True
Next
If Verif = False Then Sheets("TRAME").Copy after:=ActiveSheet
With ActiveSheet
.Name = Worksheets("RECAP").Range("B" & Ligne)
.Range("B3") = TextBoxobjet
.Range("A6") = TextBoxfiche
.Range("B6") = TextBoxdate
.Range("C6") = TextBoximputation
.Range("D6") = TextBoxlocalisation
.Range("E6") = ComboBox1
.Range("F6") = TextBoxannée
.Range("G6") = ComboBox4
.Range("A9") = TextBoxconstat
.Range("E11") = CheckBox1
.Range("E12") = CheckBox2
.Range("E13") = CheckBox3
.Range("A16") = TextBoxrisque
.Range("A21") = TextBoxorigine
.Range("A26") = TextBoxconservatoires
.Range("A30") = TextBoxtravaux
.Range("A35") = TextBoxobservation
.Range("H15") = TextBoxconstructeur
.Range("K17") = TextBoxdureevie1
.Range("K18") = TextBoxdureevie2
.Range("H20") = TextBoximage
End With
Unload UserForm3
End Sub
A dispo