locked
Filter a multi-column listbox RRS feed

  • Question

  • Hello.

    I am trying to filter a multi column iistbox using a textbox.  The way i had it before worked but it only displays one column, however i need it to display three columns.  i had it to where it would display just the Task Title column, now I need it to display the Task type title and Task Number title.  

    Thanks for any help in advance

    This is my Code -

    Private Sub txtSearchTasks_Change()
        Dim StrSource As String
        StrSource = "SELECT Task_Type.Title, Training_Tasks.Title, Training_Tasks.Task_Number" & _
                    "FROM Task_Type INNER JOIN Training_Tasks ON Task_Type.ID = Training_Tasks.Task_Type.Value;" & _
                    "WHERE Training_Tasks.Task Like '*" & Me.txtSearchTasks.Text & "*'"
                    Me.lstIndvidualTasks.RowSource = StrSource
        
    End Sub


    olu Solaru

    Friday, June 28, 2019 4:54 PM

All replies

  • Are you sure that the Column Count property of the list box has been set to 3?

    And if so, that the Column Widths property is either blank, or it specifies non-zero column widths?


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Friday, June 28, 2019 7:05 PM
  • I think this will solve your problem.

    Private Sub txtSearchTasks_Change()
        Dim StrSource As String
    
      Me.txtSearchTasks.SetFocus
    
      Me.lstIndvidualTasks.ColumnCount = 3
    
        StrSource = "SELECT Task_Type.Title, Training_Tasks.Title, Training_Tasks.Task_Number" & _
                    "FROM Task_Type INNER JOIN Training_Tasks ON Task_Type.ID = Training_Tasks.Task_Type.Value;" & _
                    "WHERE Training_Tasks.Task Like '*" & Me.txtSearchTasks.Text & "*'"
             
    
          Me.lstIndvidualTasks.RowSource = StrSource
          Me.lstIndvidualTasks.Requery
    
          Me.txtSearchTasks.SetFocus
    
    End Sub
    
    
    

    The line Me.lstIndvidualTasks.ColumnCount = 3  tell the list to show three columns

    Asaf



    Saturday, June 29, 2019 11:53 AM