(SOLVED) ListView is incoherent after a filter

%3CLINGO-SUB%20id%3D%22lingo-sub-2638868%22%20slang%3D%22en-US%22%3ERe%3A%20ListView%20is%20incoherent%20after%20a%20filter%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2638868%22%20slang%3D%22en-US%22%3EGood%20Morning%3CBR%20%2F%3EI%20still%20can't%20solve%20the%20problem%20and%20I%20would%20like%20to%20know%20if%20it%20is%20possible%20to%20filter%20a%20Listview%20or%20not.%20If%20not%2C%20I%20try%20to%20resolve%20it%20by%20another%20path.%20Thanks%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2624308%22%20slang%3D%22en-US%22%3E(SOLVED)%20ListView%20is%20incoherent%20after%20a%20filter%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2624308%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20Morning%3CBR%20%2F%3EAfter%20making%20a%20data%20filter%20in%20the%20Listview%2C%20I%20see%20that%20the%20filter%20is%20carried%20out%20in%20the%20data%20base%20sheet%20and%20that%20the%20Listview%20shows%20only%20the%20filtered%20lines.%3CBR%20%2F%3EBut%20when%20choosing%20a%20row%20in%20the%20Listview%2C%20the%20Textbox%20is%20filled%20with%20data%20from%20another%20row.%20As%20if%20the%20filter%20hadn't%20been%20done%2C%3CBR%20%2F%3EHow%20can%20I%20resolve%20this%20situation%3F%20Thank%20you%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3EPrivate%20Sub%20CASAS_LView_Casas_ItemClick(ByVal%20Item%20As%20MSComctlLib.ListItem)%0A%20%20%20%20Dim%20v_Contador%20As%20Integer%0A%20%20%20%20Dim%20v_Ultlinha%20As%20Integer%0A%20%20%20%20'In%20listview%20the%20first%20line%20is%201%20but%20in%20BD%20the%20first%20line%20is%203%0A%20%20%20%20v_LinhaList%20%3D%20Item.Index%20%2B%202%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20v_Ultlinha%20%3D%20Folha20.ListObjects(%22BDR_Casas%22).DataBodyRange.Rows.Count%0A%20%20%20%20%20%0A%20%20%20%20For%20v_Contador%20%3D%201%20To%20v_Ultlinha%0A%20%20%20%20%20%20%20%20Form_01_Entrada.MultiPage1.Pages(2).CBox_Casas_Obras.Value%20%3D%20Folha20.Cells(v_LinhaList%2C%202)%20%0A%20%20%20%20%20%20%20%20Form_01_Entrada.MultiPage1.Pages(2).Casas_TextBox3.Value%20%3D%20Folha20.Cells(v_LinhaList%2C%203)%20%0A%20%20%20%20%20%20%20%20Form_01_Entrada.MultiPage1.Pages(2).CBox_Casas_CasasDesc.Value%20%3D%20Folha20.Cells(v_LinhaList%2C%204)%20%0A%20%20%20%20Next%0AEnd%20Sub%0A%0A'______________________________________________________________________________________________________%0A%0APrivate%20Sub%20CASAS_ComboBox_P02_Casaschange()%0A%20%20%20%20Dim%20v_MPage2%20As%20Variant%0A%20%20%20%20Set%20v_MPage2%20%3D%20Form_01_Entrada.MultiPage1.Pages(2)%0A%20%20%20%20If%20v_MPage2.ComboBox_P02_Casas.Value%20%3D%20%22Codigo%22%20Then%0A%20%20%20%20%20%20%20%20Folha20.ListObjects(%22BDR_Casas%22).Range.AutoFilter%20Field%3A%3D2%2C%20Criteria1%3A%3D%22%3D*%22%20%26amp%3B%20v_MPage2.TextBox_P02_Casas%20%26amp%3B%20%22*%22%2C%20Operator%3A%3DxlAnd%0A%20%20%20%20%20%20%20%20Call%20CASAS_Listview_Create%0A%20%20%20%20End%20If%0A%20%20%20%20If%20v_MPage2.ComboBox_P02_Casas.Value%20%3D%20%22Obra%22%20Then%0A%20%20%20%20%20%20%20%20Folha20.ListObjects(%22BDR_Casas%22).Range.AutoFilter%20Field%3A%3D3%2C%20Criteria1%3A%3D%22%3D*%22%20%26amp%3B%20v_MPage2.TextBox_P02_Casas%20%26amp%3B%20%22*%22%2C%20Operator%3A%3DxlAnd%0A%20%20%20%20%20%20%20%20Call%20CASAS_Listview_Create%0A%20%20%20%20End%20If%0A%20%20%20%20If%20v_MPage2.ComboBox_P02_Casas.Value%20%3D%20%22Casa%22%20Then%0A%20%20%20%20%20%20%20%20Folha20.ListObjects(%22BDR_Casas%22).Range.AutoFilter%20Field%3A%3D4%2C%20Criteria1%3A%3D%22%3D*%22%20%26amp%3B%20v_MPage2.TextBox_P02_Casas%20%26amp%3B%20%22*%22%2C%20Operator%3A%3DxlAnd%0A%20%20%20%20%20%20%20%20Call%20CASAS_Listview_Create%0A%20%20%20%20End%20If%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2624308%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

Good Morning
After making a data filter in the Listview, I see that the filter is carried out in the data base sheet and that the Listview shows only the filtered lines.
But when choosing a row in the Listview, the Textbox is filled with data from another row. As if the filter hadn't been done,
How can I resolve this situation? Thank you for your help.

 

 

Private Sub CASAS_LView_Casas_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim v_Contador As Integer
    Dim v_Ultlinha As Integer
    'In listview the first line is 1 but in BD the first line is 3
    v_LinhaList = Item.Index + 2                 
    v_Ultlinha = Folha20.ListObjects("BDR_Casas").DataBodyRange.Rows.Count
     
    For v_Contador = 1 To v_Ultlinha
        Form_01_Entrada.MultiPage1.Pages(2).CBox_Casas_Obras.Value = Folha20.Cells(v_LinhaList, 2) 
        Form_01_Entrada.MultiPage1.Pages(2).Casas_TextBox3.Value = Folha20.Cells(v_LinhaList, 3) 
        Form_01_Entrada.MultiPage1.Pages(2).CBox_Casas_CasasDesc.Value = Folha20.Cells(v_LinhaList, 4) 
    Next
End Sub

'______________________________________________________________________________________________________

Private Sub CASAS_ComboBox_P02_Casaschange()
    Dim v_MPage2 As Variant
    Set v_MPage2 = Form_01_Entrada.MultiPage1.Pages(2)
    If v_MPage2.ComboBox_P02_Casas.Value = "Codigo" Then
        Folha20.ListObjects("BDR_Casas").Range.AutoFilter Field:=2, Criteria1:="=*" & v_MPage2.TextBox_P02_Casas & "*", Operator:=xlAnd
        Call CASAS_Listview_Create
    End If
    If v_MPage2.ComboBox_P02_Casas.Value = "Obra" Then
        Folha20.ListObjects("BDR_Casas").Range.AutoFilter Field:=3, Criteria1:="=*" & v_MPage2.TextBox_P02_Casas & "*", Operator:=xlAnd
        Call CASAS_Listview_Create
    End If
    If v_MPage2.ComboBox_P02_Casas.Value = "Casa" Then
        Folha20.ListObjects("BDR_Casas").Range.AutoFilter Field:=4, Criteria1:="=*" & v_MPage2.TextBox_P02_Casas & "*", Operator:=xlAnd
        Call CASAS_Listview_Create
    End If
End Sub

 

 

 

1 Reply
Good Morning
I still can't solve the problem and I would like to know if it is possible to filter a Listview or not. If not, I try to resolve it by another path. Thanks