Link to home
Start Free TrialLog in
Avatar of ExpExchHelp
ExpExchHelpFlag for United States of America

asked on

Unselect values from listbox(es)

I use a several (unbound) listboxes on a form (for filtering records).

I'd like to include a "Clear Filter" cmdButton that will UNSELECT all select values (not rowsource) in the listboxes.   Pls keep in mind that my listboxes are Multi-Select = "Expanded".

The code "Me.lstCTM.RowSource = Null" did not work.

EEH
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image


sub ClearListBox()
dim j

with me.listboxName
   for each j in .itemsselected
          .selected(j)=false
   next
end with
end sub
Avatar of ExpExchHelp

ASKER

Capricorn,

thanks, that works great.   Is there a way to unselect several listboxes within one statement?   Or do I need to create a loop for each listbox?

EEH
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That works perfect!!!

Thanks so much,
EEH
Avatar of PissingSkunk
PissingSkunk

What about just putting nothing in the control:

Me.lstCTM = ""

PS
PissingSkunk,
did you ever tried that before posting?
Yes, but you obviously not before commenting....
Works for me in A97, A200, A2002 and A2007.
Give it a try and report the results :-)

PS
how do you think that the code you posted will *unselect* selected items from a list box?
How do you think that it doesn't ?

PS
Ping...

Took the time to test ?

PS
And ?

PS