I have a form with 2 combo boxes and 1 listbox. The listbox is populated when I search using a button and a text box. Each combo box independently filters the listbox, but I can not figure out how to get them to layer. i.e. if I have chosen selections in both combo boxes, I would like both of the filters to apply to the listbox.
I would like to do one of the following: a) Get the filters to layer dynamically based or b) Have the filters apply when the search button is clicked
My current layout is:
Combo Boxes: cboJob, cboCompany ListBox: lstResume Textbox for searching: txtKeywords Search Button: btnSearch data is drawn from qryResume All data is text
Current Code:
Private Sub btnSearch_Click()
Dim SQL As String
SQL = "SELECT qryResume.ID, qryResume.Company, qryResume.Job, qryResume.LastUpdated " _
& "FROM qryResume " _
& "Where Company LIKE '*" & Me.txtKeywords & "*' " _
& " OR Job LIKE '*" & Me.txtKeywords & "*' " _
& "ORDER BY qryResume.Company "
Me.lstResume.RowSource = SQL
Me.lstResume.Requery
End Sub
Private Sub cboCompany_AfterUpdate()
Dim SQL As String
SQL = "SELECT qryResume.ID, qryResume.Company, qryResume.Job, qryResume.LastUpdated " _
& "FROM qryResume " _
& "WHERE qryResume.Company = '" & cboCompany.Text & "'" _
& "ORDER BY qryResume.Company"
Me.lstResume.RowSource = SQL
Me.lstResume.Requery
End Sub
Private Sub cboJob_AfterUpdate()
Dim SQL As String
SQL = "SELECT qryResume.ID, qryResume.Company, qryResume.Job, qryResume.LastUpdated " _
& "FROM qryResume " _
& "WHERE qryResume.Job = '" & cboJob.Text & "'" _
& "ORDER BY qryResume.Company"
Me.lstResume.RowSource = SQL
Me.lstResume.Requery
End Sub