Clear Multiselect List box

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

Found this multiSelect Listbox on Applecore Pages on Microsoft Access and I
got it to work very nicely. I just can't figure out what I have to do to
reset the selection
Can someone tell me how I can do that?
Anne

Private Sub cmdPrint_Click()
Dim varSelected As Variant
Dim strSQL As String
For Each varSelected In Me!lstSelect.ItemsSelected
strSQL = strSQL & Me!lstSelect.ItemData(varSelected) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[JobID] IN (" & Left(strSQL, Len(strSQL) - 1) & ")"
DoCmd.OpenReport "rptEntry", acViewNormal, , strSQL
End If
End Sub
 
Hi,
To clear all selections:
Dim i As Integer

For i = 0 To lstSelect.ListCount - 1
Me.lstSelect.Selected(i) = False
Next
 
I probably shouldn't jump in here since I never use list
boxes, but I have a vague memory that there are situations
where the only way to clear all selected items is to reset
the list box's RowSource:

Me.kistbos.RowSource = Me.kistbos.RowSource
 
Thanks to both of you.
I tried both, just to see.
Dan Artuso's answer worked perfectly.
Marshall Barton's did not do it.
Anne
 
Back
Top