Clear Multiselect List box

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
 
D

Dan Artuso

Hi,
To clear all selections:
Dim i As Integer

For i = 0 To lstSelect.ListCount - 1
Me.lstSelect.Selected(i) = False
Next
 
M

Marshall Barton

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
 
A

Anne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top