bradyboyy88
Well-known Member
- Joined
- Feb 25, 2015
- Messages
- 562
I have a listbox with unique values using a scripting.dictionary object but all the items are out of order. Is there a way to sort alphabetically using the scripting.dictionary object?
Code:
Private Sub ActivateFILTER_BROWSE(FilterButt*******ed_BROWSE As MSForms.Label, Field As String)
Dim FilterList As Scripting.Dictionary, item, tmp As String
Set FilterList = CreateObject("scripting.dictionary")
FilterBoxListbox_BROWSE.Clear
ActiveRecordset.MoveFirst
Do While Not ActiveRecordset.EOF
tmp = Trim(ActiveRecordset.Fields(Field).Value)
If Len(tmp) > 0 Then FilterList(tmp) = FilterList(tmp) + 1
ActiveRecordset.MoveNext
Loop
FilterBoxListbox_BROWSE.AddItem "Select All"
For Each item In FilterList.Keys
FilterBoxListbox_BROWSE.AddItem item
Next item
Set FilterList = Nothing
If FilterButt*******ed_BROWSE.Left + FilterBoxFrame_BROWSE.Width > BrowseFrame.Width Then
FilterBoxFrame_BROWSE.Top = FilterButt*******ed_BROWSE.Top
FilterBoxFrame_BROWSE.Left = FilterButt*******ed_BROWSE.Left - FilterBoxFrame_BROWSE.Width
Else
FilterBoxFrame_BROWSE.Top = FilterButt*******ed_BROWSE.Top
FilterBoxFrame_BROWSE.Left = FilterButt*******ed_BROWSE.Left
End If
EnableEvents = True
Call HighlightCollectionItems(LastCollecti*******ed_BROWSE)
EnableEvents = False
FilterBoxFrame_BROWSE.ZOrder (0)
FilterBoxFrame_BROWSE.Visible = True
End Sub