Results 1 to 3 of 3
  1. #1
    JJCHCK is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    30

    Filter listview

    Hi everyboy
    i have a listview where I can't filter it with a combo

    what i have to do?
    Code:
    Public Sub FillSales()
        On Error GoTo ErrorHandler
        Dim rs As DAO.Recordset
        Dim db As Database
        Dim lstItem As ListItem
        Dim strsql As String
        Dim strClie As String
        
       ' strClie = [Maschera1]![Form]![Testo1]
        
        Set db = CurrentDb()
        
        strsql = "SELECT * FROM Storico WHERE (Rt1Codcli = '" & [Maschera1]![Form]![Testo1] & "')  order by Rt1Codcen"
          
        Set rs = db.OpenRecordset(strsql)
        
       ' rs.Filter = "Rt1Codcli   =  '" & strClie & "'"
        
        With Form_Maschera1.lsvClienti
           
           .View = lvwReport
           .GridLines = True
           .FullRowSelect = True
           .ListItems.Clear
           .ColumnHeaders.Clear
            
        End With
     
                                                
        With Form_Maschera1.lsvClienti.ColumnHeaders
            .Add , , "Anno", 1000, lvwColumnLeft
            .Add , , "Codcen", 2000, lvwColumnLeft
            .Add , , "Codcli", 2000, lvwColumnLeft
            .Add , , "Ragso1", 2000, lvwColumnLeft
            .Add , , "Nome", 2000, lvwColumnLeft
            .Add , , "quantità", 2000, lvwColumnLeft
            .Add , , "fatturato", 2000, lvwColumnLeft
        End With
        
        rs.MoveFirst
        Do Until rs.EOF
            Set lstItem = Form_Maschera1.lsvClienti.ListItems.Add()
            
            lstItem = Nz(Trim(rs!Anno))
            lstItem.SubItems(1) = Format(rs!Codcen, "<")
            lstItem.SubItems(2) = Format(rs!Codcli, "<")
            lstItem.SubItems(3) = UCase(Format(rs!Ragso1, "<"))
            lstItem.SubItems(4) = UCase(Format(rs!Nome, "<"))
            lstItem.SubItems(5) = Format(rs!quantità, "##,##0.00#")
            lstItem.SubItems(6) = Format(rs!fatturato, "##,##0.00#")
            rs.MoveNext
        Loop
        
        rs.Close
        DoCmd.Echo True
    ErrorHandlerExit:
        Exit Sub
    ErrorHandler:
        If Err = 3021 Then
            Resume Next
        Else
            MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
            Resume ErrorHandlerExit
        End If
    End Sub


  2. #2
    stmoong is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    108
    You can use the On Click event of the combo box to run some VBA code to run the query and set the new values. Probably you have to clear the values from the listbox first.

  3. #3
    JJCHCK is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    30
    Hi atthache my mdb...could you look it ...i don't understand how to do

    tkhs for answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. SQL Filter?
    By dev82 in forum Programming
    Replies: 4
    Last Post: 08-22-2011, 05:35 AM
  2. Listview pulling data from a second table
    By Yesideez in forum Access
    Replies: 8
    Last Post: 06-29-2011, 05:08 AM
  3. Slow response over VPN or To Filter or not To Filter
    By rcrobman in forum Database Design
    Replies: 0
    Last Post: 04-30-2011, 02:37 PM
  4. Unselect listview items in OnCurrent event
    By majq in forum Programming
    Replies: 0
    Last Post: 02-21-2011, 07:51 AM
  5. Transfer data from ListView to Table
    By Zyckie in forum Access
    Replies: 1
    Last Post: 12-15-2009, 11:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums