listview et problème modification données

deeppurple

XLDnaute Nouveau
Cijoint.fr - Service gratuit de dépôt de fichiers

bonjour le forum,

j'ai un souci avec mes listview dans usf recapclients(qui est rattachée à ma feuille"entrée" et feuille"entrée1)
quand je cherche un client (par exemple agfa ) dans ma listview de gauche ca me marque mes données de ma feuille"entrée"(je voudrais que toutes les entrées de ce client arrive à gauche et dans ma listview de droite quand je clique sur la première ligne , ça affiche les données de ma feuille"entrée1"

mais je n'ai qu'une entrée qui s'affiche alors que dans mes deux feuilles j'ai plusieurs données qui correspondent à ce client;

Si vous pouvez me donner un petit coup de main cela me permettrait d'avancer car cela fait deux week que j'essaie de trouver et je suis coincée pour avancer dans ce projet .

Et mon mon usf client quand je veux modifier un client cela me crée une nouvelle ligne, que dois je rajouter (ou modifier)à mon code pour que cela marche

ci dessous c'est mon code de mon usf recapclients
Code:
Private Sub ComboBox1_Click()
Dim c As Object ' Variable résultat de la recherche
Dim iLignes, iLig As Integer, Lst As ListItem
   ' Recherche du nombre de ligne de la plage de données
    iLignes = Application.WorksheetFunction.CountA(Range("clients!A:A"))
    ' La recherche s'effectue dans la plage A2:Axx de la feuille Feuil1
    With Range("clients!A2:A" & iLignes)
        Set c = .Find(What:=Trim(ComboBox1), LookIn:=xlValues, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False)
        On Error Resume Next
        Me.TextBox4 = c.Offset(0, 1)
        Me.TextBox6 = c.Offset(0, 2)
        Me.TextBox7 = c.Offset(0, 3)
        Me.TextBox8 = c.Offset(0, 4)
        Me.TextBox9 = c.Offset(0, 5)
        Me.TextBox10 = c.Offset(0, 6)
        Me.TextBox11 = c.Offset(0, 7)
        Me.TextBox12 = c.Offset(0, 8)
        Me.TextBox13 = c.Offset(0, 9)
        Me.TextBox14 = c.Offset(0, 10)
        Me.TextBox15 = c.Offset(0, 11)
    End With
    ListeBons.ListItems.Clear
    With ThisWorkbook.Worksheets("ENTREE")
        iLig = 7
        While .Cells(iLig, 3) <> ""
            If .Cells(iLig, 6) = ComboBox1.Text Then
                Set Lst = ListeBons.ListItems.Add(, , .Cells(iLig, 3))
                Lst.ListSubItems.Add , , .Cells(iLig, 1)
                Lst.ListSubItems.Add , , .Cells(iLig, 37)
                Lst.ListSubItems.Add , , .Cells(iLig, 36)
            End If
            iLig = iLig + 1
        Wend
    End With
   
    If ListeBons.ListItems.Count > 0 Then
        ListeBons.ListItems(1).Selected = True
        ListeBons.SetFocus
       ListeBons_ItemClick ListeBons.ListItems(1)
    End If
    'Remplissage de la 1ere colonne (création de 3 lignes)
      '.Add , , "10"
      'ListeBons.ListItems(1).ListSubItems.Add , , "########"
       '.Add , , "20"
        'ListeBons.ListItems(2).ListSubItems.Add , , "########"
       '.Add , , "30"
       'ListeBons.ListItems(3).ListSubItems.Add , , "########"
       '.Add , , "40"
       'ListeBons.ListItems(4).ListSubItems.Add , , "########"
    'End With
    'Remplissage des colonnes 2 et 3 dans la 1ere ligne
    ' Format(1234567.89, "##,##0.00")
    '.ListItems(1).ListSubItems.Add , , "Compte 6021111"
    '.ListItems(1).ListSubItems.Add , , Format(120000, "##,##0.00")
    '.ListItems(1).ListSubItems.Add , , Format(10000, "##,##0.00")
    
    

End Sub



Private Sub CommandButton1_Click()
frmspecific.Show
Unload Me
End Sub

Private Sub ListeBons_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim sNum As String, Lst As ListItem, iLig As Integer
    sNum = Item.Text
    ListeDetail.ListItems.Clear
    With ThisWorkbook.Worksheets("ENTREE1")
        iLig = 2
     
        While .Cells(iLig, 2) <> ""
            If .Cells(iLig, 2) = sNum Then
                Set Lst = ListeDetail.ListItems.Add(, , .Cells(iLig, 5))
                Lst.ListSubItems.Add , , .Cells(iLig, 6)
                Lst.ListSubItems.Add , , .Cells(iLig, 7)
                
            End If
            iLig = iLig + 1
        Wend
       
    End With
End Sub



Private Sub ListeDetail_BeforeLabelEdit(Cancel As Integer)

End Sub

Private Sub UserForm_Initialize()
With ListeBons
            .FullRowSelect = True
            .Gridlines = True
            With .ColumnHeaders
                .Clear
                .Add , , "N°BL", 60
                .Add , , "Date", 65
                .Add , , "Nbre", 65
                .Add , , "Pds", 65
                
            End With
    End With
    With ListeDetail
            .FullRowSelect = True
            .Gridlines = True
            With .ColumnHeaders
                .Clear
                .Add , , "Réference Produit", 150
                .Add , , "Nombre", 55, lvwColumnRight
                .Add , , "Poids", 55, lvwColumnRight
                
            End With
    End With
    Sheets("clients").Activate
Dim iLignes As Integer
     iLignes = Application.WorksheetFunction.CountA(Range("clients!A:A"))
    Me.ComboBox1.RowSource = "=clients!$A$2:$A" & iLignes
 

End Sub

ci-dessous c'est le code de mon usf clients
Code:
Private Sub clnomsociete_Change()
Dim c As Object ' Variable résultat de la recherche
Dim iLignes As Integer
    ' Recherche du nombre de ligne de la plage de données
    iLignes = Application.WorksheetFunction.CountA(Range("clients!A:A"))
    ' La recherche s'effectue dans la plage A2:Axx de la feuille Feuil1
    With Range("clients!A2:A" & iLignes)
        Set c = .Find(What:=Trim(clnomsociete), LookIn:=xlValues, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False)
        On Error Resume Next
        ' Le textBox txtNomreçoit la valeur contenue dans la colonne B de la ligne correspondant à la référence cherchée
        Me.adresse = c.Offset(0, 1)
        Me.adress1 = c.Offset(0, 2)
        Me.ComboBoxcp = c.Offset(0, 3)
        Me.ComboBoxville = c.Offset(0, 4)
        Me.Combotitre = c.Offset(0, 5)
        Me.Combocontact = c.Offset(0, 6)
        Me.TextBoxtel = c.Offset(0, 7)
        Me.TextBoxport = c.Offset(0, 8)
        Me.TextBoxfax = c.Offset(0, 9)
        Me.TextBoxmail = c.Offset(0, 10)
        Me.TextBoxsiteweb = c.Offset(0, 11)
    End With
 
End Sub
Private Sub clnomsociete_DropButtonClick()
'Dim c As Object
'Dim iLignes As Integer
'    ' Recherche du nombre de ligne de la plage de données
'    iLignes = Application.WorksheetFunction.CountA(Range("feuil1!A:A"))
'
'    ' La recherche s'effectue dans la plage A2:Axx de la feuille Feuil1
'    With Range("clients!A2:A" & iLignes)
'        Set c = .Find(What:=Trim(clNomSociete), LookIn:=xlValues, _
'                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
'                MatchCase:=False, SearchFormat:=False)
'        On Error Resume Next
'        ' Le textBox txtNomreçoit la valeur contenue dans la colonne B de la ligne correspondant à la référence cherchée
'        txtNom.Text = c.Offset(0, 1)
'        txtAdresse.Text = c.Offset(0, 2)
'
'    End With
'
'End Sub
End Sub

Private Sub CommandButton7_Click()
Me.PrintForm
End Sub

Private Sub UserForm_Initialize()
Sheets("clients").Activate
Dim iLignes As Integer
     iLignes = Application.WorksheetFunction.CountA(Range("clients!A:A"))
    Me.clnomsociete.RowSource = "=clients!$A$2:$A" & iLignes
Sheets("liste de choix").Activate
For i = 1 To 42680
Me.ComboBoxcp.AddItem Range("B" & i).Value
Me.ComboBoxville.AddItem Range("A" & i).Value
Next
For i = 1 To 2
Me.Combotitre.AddItem Range("F" & i).Value
Next
'Userform en plein écran
Me.Width = ScreenWidth * PointsPerPixel - 3
Me.Height = ScreenHeight * PointsPerPixel
'Rapport d'agrandissement de la form/taille écran en points
Dim RW As Single, RH As Single
RW = ScreenWidth * PointsPerPixel / Me.Width
RH = ScreenHeight * PointsPerPixel / Me.Height
With FrmClient
.StartUpPosition = 3
.Width = Application.Width
.Height = Application.Height
.Left = 0
.Top = 0
End With
End Sub

Private Sub ComboBoxcp_Change()
ComboBoxville.ListIndex = ComboBoxcp.ListIndex
ComboBoxville.Value = ComboBoxville.List(ComboBoxville.ListIndex)
End Sub
Private Sub ComboBoxville_Change()
ComboBoxcp.ListIndex = ComboBoxville.ListIndex
ComboBoxcp.Value = ComboBoxcp.List(ComboBoxcp.ListIndex)
End Sub
Private Sub CommandButton1_Click() 'spécificités
Me.Hide
Op = "spécificités"
frmspecific.Show
End Sub
Private Sub CommandButton2_Click()
Me.Hide
Op = " retour menu"
frmmenu.Show
End Sub
Private Sub CommandButton4_Click() 'bons
With Sheets("clients")
If ligSelect = 0 Then ligSelect = .Range("A" & Cells.Rows.Count).End(xlUp).Row + 1
Range("A" & ligSelect) = clnomsociete.Value
Range("B" & ligSelect) = adresse.Value
Range("C" & ligSelect) = adress1.Value
Range("D" & ligSelect) = ComboBoxcp.Value
Range("E" & ligSelect) = ComboBoxville.Value
Range("F" & ligSelect) = Combotitre.Value
Range("G" & ligSelect) = Combocontact.Value
Range("H" & ligSelect) = TextBoxtel.Value
Range("I" & ligSelect) = TextBoxport.Value
Range("J" & ligSelect) = TextBoxfax.Value
Range("K" & ligSelect) = TextBoxmail.Value
Range("L" & ligSelect) = TextBoxsiteweb.Value
End With
End Sub
Private Sub Commandvalider_Click()
Dim iLigne As Integer
Sheets("clients").Activate

Societeconverti = Application.WorksheetFunction.Proper(Me.clnomsociete.Text)
Villeconverti = Application.WorksheetFunction.Proper(Me.ComboBoxville.Text)
Contactconverti = Application.WorksheetFunction.Proper(Me.Combocontact.Text)
 
iLigne = LigneRechercher("nom")
 
Range("A" & iLigne) = clnomsociete.Value
Range("B" & iLigne) = adresse.Value
Range("C" & iLigne) = adress1.Value
Range("D" & iLigne) = ComboBoxcp.Value
Range("E" & iLigne) = ComboBoxville.Value
Range("F" & iLigne) = Combotitre.Value
Range("G" & iLigne) = Combocontact.Value
Range("H" & iLigne) = TextBoxtel.Value
Range("I" & iLigne) = TextBoxport.Value
Range("J" & iLigne) = TextBoxfax.Value
Range("K" & iLigne) = TextBoxmail.Value
Range("L" & iLigne) = TextBoxsiteweb.Value
Unload Me
End Sub
Function LigneRechercher(sTexteCherche As String) As Integer
Dim c As Object
With Worksheets(1).Range("a1:a65536")
    Set c = .Find(sTexteCherche, LookIn:=xlValues)
    If Not c Is Nothing Then
        LigneRechercher = c.Row
    Else
        LigneRechercher = Range("A65536").End(xlUp).Offset(1, 0).Row
    End If
End With
End Function

si le forum pouvez m'aider à m'en sortir
 

Bebere

XLDnaute Barbatruc
Re : listview et problème modification données

bonjour
ajout de 'option compare text' en début de page
combobox1. list sans doublons(voir userform initialize
changer code de combobox1.change et ListeBons_ItemClick
tu rectifies le choix des colonnes,s'il le faut

Option Compare Text

Private Sub ComboBox1_Change()
Dim C As Range ' Variable résultat de la recherche
Dim iLignes, iLig As Integer, Lst As ListItem

If ComboBox1.ListIndex = -1 Then Exit Sub
' Recherche du nombre de ligne de la plage de données
iLignes = ComboBox1.ListIndex + 6
' La recherche s'effectue dans la plage A2:Axx de la feuille Feuil1
With Worksheets("clients")
Me.TextBox4 = .Cells(iLignes, 2) 'C.Offset(0, 1)
Me.TextBox6 = .Cells(iLignes, 3) 'C.Offset(0, 2)
Me.TextBox7 = .Cells(iLignes, 4) 'C.Offset(0, 3)
Me.TextBox8 = .Cells(iLignes, 5) 'C.Offset(0, 4)
Me.TextBox9 = .Cells(iLignes, 6) 'C.Offset(0, 5)
Me.TextBox10 = .Cells(iLignes, 7) 'C.Offset(0, 6)
Me.TextBox11 = .Cells(iLignes, 8) 'C.Offset(0, 7)
Me.TextBox12 = .Cells(iLignes, 9) 'C.Offset(0, 8)
Me.TextBox13 = .Cells(iLignes, 10) 'C.Offset(0, 9)
Me.TextBox14 = .Cells(iLignes, 11) 'C.Offset(0, 10)
Me.TextBox15 = .Cells(iLignes, 12) 'C.Offset(0, 11)
End With

ListeBons.ListItems.Clear
With Worksheets("entree")
Set C = .Columns("F").Find(Trim(ComboBox1), LookIn:=xlValues)
If Not C Is Nothing Then
firstAddress = C.Address
Do
Set Lst = ListeBons.ListItems.Add(, , C.Offset(0, -3))
Lst.ListSubItems.Add , , C.Offset(0, -5).Text
Lst.ListSubItems.Add , , C.Offset(0, 1).Text
Lst.ListSubItems.Add , , C.Offset(0, 2).Text
Set C = .Columns("f").FindNext(C)
Loop While Not C Is Nothing And C.Address <> firstAddress
End If
End With

End Sub


Private Sub ListeBons_ItemClick(ByVal Item As MSComctlLib.ListItem)

Dim sNum As String, Lst As ListItem, iLig As Integer

sNum = ListeBons.ListItems.Item(ListeBons.SelectedItem.Index).Text
iLig = 2

ListeDetail.ListItems.Clear
With ThisWorkbook.Worksheets("ENTREE1")
While .Cells(iLig, 2) <> ""
If .Cells(iLig, 2).Text = sNum Then
Set Lst = ListeDetail.ListItems.Add(, , .Cells(iLig, 5))
Lst.ListSubItems.Add , , .Cells(iLig, 6)
Lst.ListSubItems.Add , , .Cells(iLig, 7)

End If
iLig = iLig + 1
Wend

End With
End Sub

Private Sub UserForm_Initialize()
With ListeBons
.FullRowSelect = True
.Gridlines = True
With .ColumnHeaders
.Clear
.Add , , "N°BL", 60
.Add , , "Date", 65
.Add , , "Nbre", 65
.Add , , "Pds", 65

End With
End With
With ListeDetail
.FullRowSelect = True
.Gridlines = True
With .ColumnHeaders
.Clear
.Add , , "Réference Produit", 150
.Add , , "Nombre", 55, lvwColumnRight
.Add , , "Poids", 55, lvwColumnRight

End With
End With
' Sheets("clients").Activate
Dim Cel As Range, DerL As Integer

Set mondico = CreateObject("Scripting.Dictionary")

With Worksheets("entree")
DerL = .Range("F65536").End(xlUp).Row

.Range("A5:S" & DerL).Sort Key1:=.Range("F6"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

For Each Cel In .Range("F6:F" & DerL)
If Not mondico.Exists(Cel.Value) Then mondico.Add Cel.Value, Cel.Value
Next Cel
End With

Me.ComboBox1.List = mondico.items
Set mondico = Nothing
End Sub

à bientôt
 

deeppurple

XLDnaute Nouveau
Re : listview et problème modification données

bonjour bebere

merci pour ton code

par contre peux tu me donner un conseil pour mon usf client

quand je cherche un client (pas de problème) mais quand je veux ajouter une donnée ou la modifier, au moment de mon enregistrement sur ma feuille"clients", il me crée une entrée : je voudrais qu'il me modifie le client, mais ca je ne sais pas comment on fait

peux-tu m'aider?
 

Discussions similaires

Réponses
1
Affichages
164

Statistiques des forums

Discussions
312 149
Messages
2 085 771
Membres
102 970
dernier inscrit
JMaurice