galopin01 a écrit :
bonsoir,
Normalement un formulaire Ajout/Recherche n'a pas besoin de bouton modifier : un bouton Ok suffit.
Si on part de rien Ok est en mode Ajout
Si on part d'une recherche Ok est en mode modification (si la recherche à abouti...)
A+
Bonsoir,
En fait, le formulaire permet de remplir un fichier de vente en s'ajoutant à la 1ere ligne vide.
J'ai besoin du bouton modifier pour modifier des clients existants (changement d'adresse, de commande par exemple).
Je vous joint mon code, c'est peut etre gros comme une maison maison je vois plus
Private Sub CommandModif_Click()
Dim nom, nodos, i As Integer
Sheets("Clients").Select
If Combonom.Value = "" And Combonodos.Value = "" Then MsgBox ("Merci de selectionner un client ou un numéro de dossier.")
If MsgBox("Voulez-vous modifier la fiche?", vbYesNoCancel, "Confirmation") = vbYes Then
nom = Me.Combonom.ListIndex + 2
nodos = Me.Combonodos.ListIndex + 2
For i = nom To nodos
Next i
Cells(i, 2) = TextDate.Value
Cells(i, 4) = ComboConseiller.Value
Cells(i, 5) = TextNom.Value
Cells(i, 6) = Textprenom.Value
Cells(i, 7) = TextAdd.Value
Cells(i, 8) = TextCP.Value
Cells(i, 10) = TextFixe.Value
Cells(i, 11) = TextPort.Value
Cells(i, 12) = Textmail.Value
Cells(i, 13) = Text200L.Value
Cells(i, 14) = Text300L.Value
Cells(i, 15) = Textclim91.Value
Cells(i, 16) = TextClim92.Value
Cells(i, 17) = TextClim12.Value
Cells(i, 18) = TextClim18.Value
Cells(i, 19) = TextClim24.Value
Cells(i, 37) = ComboStatut.Value
If OptionEconhome = True Then Cells(i, 20) = "X"
If OptionDalle = True Then Cells(i, 23) = "Dalle"
If OptionToiture = True Then Cells(i, 23) = "Toiture"
End If
Unload Me
UserForm1.Show
End Sub
Après j'ai aussi créé un bouton pour accéder à la Userform via un module. Il me l'affiche sans problème mais quand je rempli ca ne rempli pas le tableau excel alors qu'en mode test VBA création ça marche!!!
C'est mon 1er formulaire et je galère un peu alors merci pour votre aide et patience!
Camille