Filter ListBox for Multiple Groups
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Filter ListBox for Multiple Groups
I need to be able to filter my list box for multiple groups,individual or all. Your ideas would be very much appreciated. Having a brain dead day!
Last edited by burrina on 21 Oct 2014, 16:15, edited 1 time in total.
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Filter ListBox for Multiple Groups
How do you propose to filter for an individual?
A second dropdown with ONLY email address, or at least two pieces of info; group AND email address listed in the dropdown.
One for groups and <<ALL>> and the other for individual and <<ALL>>
A second dropdown with ONLY email address, or at least two pieces of info; group AND email address listed in the dropdown.
One for groups and <<ALL>> and the other for individual and <<ALL>>
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 78439
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Filter ListBox for Multiple Groups
If you want to be able to select multiple groups, you'll have to use a multi-select list box instead of the combo box cbogroup.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Filter ListBox for Multiple Groups
I tried adding a new list box and then a requery of the list box for the results with no success. What am I missing?
Changed the record source to the below to reflect the new list box.
SELECT tblEmailTo.eemailto, tblEmailGroup.egroup, tblEmailTo.eemailaddress FROM tblEmailGroup INNER JOIN tblEmailTo ON tblEmailGroup.eGroupID = tblEmailTo.eGroupID WHERE (((tblEmailGroup.egroup) Like "*" & [lstgrps]));
Changed the record source to the below to reflect the new list box.
SELECT tblEmailTo.eemailto, tblEmailGroup.egroup, tblEmailTo.eemailaddress FROM tblEmailGroup INNER JOIN tblEmailTo ON tblEmailGroup.eGroupID = tblEmailTo.eGroupID WHERE (((tblEmailGroup.egroup) Like "*" & [lstgrps]));
-
- Administrator
- Posts: 78439
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Filter ListBox for Multiple Groups
See if the attached version does what you want (I didn't bother about the details, I just changed the combo box to a list box and added the code needed to select groups).
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Filter ListBox for Multiple Groups
Almost. How can I then after DeSelecting make the ListBox show All records?
-
- Administrator
- Posts: 78439
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Filter ListBox for Multiple Groups
Change the On Click event of cbogroup to
Code: Select all
Private Sub cbogroup_Click()
Dim varItem As Variant
Dim strIn As String
For Each varItem In Me.cbogroup.ItemsSelected
strIn = strIn & "," & Me.cbogroup.ItemData(varItem)
Next varItem
If strIn <> "" Then
strIn = Mid(strIn, 2)
Me.lstlist.RowSource = "SELECT * FROM qryEmailClientsByGroup WHERE eGroupID In (" & strIn & ")"
Else
Me.lstlist.RowSource = "SELECT * FROM qryEmailClientsByGroup"
End If
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 550
- Joined: 30 Jul 2014, 23:58
Re: Filter ListBox for Multiple Groups
Thank You so much! Exactly what I was after.