Private Sub GroupeBouton_Click() 'cet evenement concerne tout les commandbuttons de l'userform
Dim Page, combo, i, ctrl, e
With Uclient
Page = .MultiPage1.Value
Select Case Left(GroupeBouton.Name, 7)
Case "valider"
'bouton valider les modifications
Set combo = .Controls("combonom" & Page)
i = combo.List(combo.ListIndex, 2)
For Each ctrl In .Controls("Frame" & Page).Controls
If TypeName(ctrl) = "TextBox" And ctrl.Tag <> "" And ctrl.Name <> "oldbouton" Then WsClient.Range(ctrl.Tag & i).Value = ctrl.Value
Next
'ici on vire le userform pas la peine de le garder en memoire
Unload Uclient
'tout les boutons annuler
Case "Annuler"
Unload Uclient
'bouton ajouter dans le listing Uclient
Case "ajouter"
With WsClient
i = .Range("B65536").End(xlUp).Row + 1
For Each ctrl In Uclient.Frame0.Controls
If TypeName(ctrl) <> "CommandButton" And ctrl.Tag <> "" Then
.Range(ctrl.Tag & i) = ctrl
ctrl = ""
End If
Next
End With
Workbooks(WsClient.Parent.Name).Save
'ici on vire le userform pas la peine de le garder en memoire
'Unload Uclient 'a la place de UserForm1.Hide
'bouton ajouter au devis
Case "ajoudev"
With wsFacture
.Range("DOC_CLIENT").Resize(6, 1).ClearContents
.Range("B2:I300").Interior.Color = xlNone
.Range("A5").Value = Uclient.Combonom2.List(, 0)
With .Range("DOC_CLIENT")
.Value = Uclient.Combocivil2.Value & " " & Uclient.Combonom2.List(, 0)
.offset(1).Value = Uclient.PRENOM2
'==================modif pour ajout à l'attention de: réussie ========================
If Uclient.ATTENTION2.Value <> "" Then
.offset(2).Value = "à l'attention de : " & Uclient.ATTENTION2.Value
.offset(3).Value = Uclient.ADRESSE2
.offset(4).Value = Uclient.COMPLEMENT2
.offset(5).Value = Uclient.cp2 & " " & Uclient.VILLE2
Else
.offset(2).Value = Uclient.ADRESSE2
.offset(3).Value = Uclient.COMPLEMENT2
.offset(4).Value = Uclient.cp2 & " " & Uclient.VILLE2
End If
End With
'=================================================================
End With
MsgBox "la case client a duement été remplie!"
Unload Uclient
wsFacture.Activate
Case "Supprim"
Set combo = .Controls("combonom" & Page)
e = combo.List(combo.ListIndex, 2)
WsClient.Rows(e).Delete Shift:=xlUp
MsgBox "Le client a bien été supprimé du listing client"
remplinom
End Select
End With
End Sub