Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clear list box selection

27 views
Skip to first unread message

C.Y.

unread,
Jul 8, 2003, 1:21:41 PM7/8/03
to

I have a multiselect List box (Multi select set to
simple), that I am trying to clear all selections after
a 'Clear Selection' command button has been pressed.

I have tried
1. me.lstSelCust.Requery
2. me.lstSelCust = Null
3. me.lstSelCust = " "
And others not worth mentioning.

The list box is populated from a table.

Can anyone provide any suggestions?

Thanks in advance
C.Y.

c.y.

unread,
Jul 8, 2003, 2:06:58 PM7/8/03
to

I actually just found the answer so I thought I would
share it in case anyone else had the same problem. You can
write a routine like the following to clear the selections
from a multi-select list box.

Sub ClearSelection()
Dim intCurrCat As Integer
For intCurrCat = 0 To me!lstSelCust.ListCount - 1
me!lstSelCust.Selected(intCurrCat) = False
Next intCurrCat
End Sub

C.Y.

Dale Fye

unread,
Jul 8, 2003, 2:10:42 PM7/8/03
to
CY

Call the following subroutine in the click event of your command
button, or copy and paste the code if this is the only listbox you
have in your application.

Public Sub ClearListbox(ctrl as control)

Dim varItem as variant
For each varItem in ctrl.ItemsSelected
ctrl.Selected(varItem) = False
Next varItem

Exit sub

--
HTH

Dale Fye


"C.Y." <C...@nomail.please> wrote in message
news:004a01c34575$65b49710$a501...@phx.gbl...

C.Y.

unread,
Jul 8, 2003, 2:16:18 PM7/8/03
to
Thanks Dale,

You were one step ahead of me!

C.Y.

>.
>

0 new messages