?
Solved

Unselect values from listbox(es)

Posted on 2007-10-19
11
Medium Priority
?
977 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:ExpExchHelp
  • 5
  • 4
  • 2
11 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20110655

sub ClearListBox()
dim j

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

Author Comment

by:ExpExchHelp
ID: 20110697
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
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 20110753
try

sub ClearListBox()
dim j, ctl as control

for each ctl in me.controls
  if ctl.controltype=aclistbox then
       with me(ctl.name)
               for each j in .itemsselected
                     .selected(j)=false
                next
        end with
  end if
next
end sub
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:ExpExchHelp
ID: 20110775
That works perfect!!!

Thanks so much,
EEH
0
 
LVL 2

Expert Comment

by:PissingSkunk
ID: 20115764
What about just putting nothing in the control:

Me.lstCTM = ""

PS
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20115880
PissingSkunk,
did you ever tried that before posting?
0
 
LVL 2

Expert Comment

by:PissingSkunk
ID: 20115997
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
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 20116005
how do you think that the code you posted will *unselect* selected items from a list box?
0
 
LVL 2

Expert Comment

by:PissingSkunk
ID: 20116015
How do you think that it doesn't ?

PS
0
 
LVL 2

Expert Comment

by:PissingSkunk
ID: 20116133
Ping...

Took the time to test ?

PS
0
 
LVL 2

Expert Comment

by:PissingSkunk
ID: 20116195
And ?

PS
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question