I need to clear selections from several listboxes at the same time.
Using Allen Browne's code shown below,
how do I pass by variable (rather than one specific listbox name) so that I can clear all selections for Listbox List0 through List7 at the same time?
I have tried
This does not work.
Please HELP!!! Thank you in advance.
Allen Browne's code:
Using Allen Browne's code shown below,
how do I pass by variable (rather than one specific listbox name) so that I can clear all selections for Listbox List0 through List7 at the same time?
I have tried
Code:
Dim i As Integer Dim strListBox As String For i=0 to 7 strListBox = "List" & i call ClearList(Me.Controls.Item(strListBox))] Next i
Please HELP!!! Thank you in advance.
Allen Browne's code:
Code:
To deselect them all:
Call ClearList(Forms!Form1!List0)
--------------------------------------------------------------------------------
Function ClearList(lst As ListBox) As Boolean
On Error GoTo Err_ClearList
'Purpose: Unselect all items in the listbox.
'Return: True if successful
'Author: Allen Browne. [url]http://allenbrowne.com[/url] June, 2006.
Dim varItem As Variant
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelected
lst.Selected(varItem) = False
Next
End If
ClearList = True
Exit_ClearList:
Exit Function
Err_ClearList:
Call LogError(Err.Number, Err.Description, "ClearList()")
Resume Exit_ClearList
End Function
Comment