Filter listbox with toggle button

L

livin''''life

I am sure this is a simple solution but i cant seem to get it. What i have
is a form with a list box that displays names of personnel. What i would
like to have happen is this:
When the form opens, all personnel are listed in the listbox (which already
works) and then i would like a toggle button on the form that will filter the
listbox when it is pressed. The control for the filter will be a yes/no box
and i would only like to see the personnel with 'yes' checked.

Thank you for your help.
 
T

tkelley via AccessMonster.com

There are a handful of ways to do this. Here is one:

Create a second query to reflect the 'yes' criteria (or dynamic SQL string ...
whichever you're using and makes the most sense to you). When clicking the
toggle in the After_Update event:

If me.togglebutton = true then
me.listbox.rowsource = qryWithYesCriteria (or dynamic SQL string)
else
me.listbox.rowsource = qryDefaultThatLoadsWithForm (or dynamic SQL string)
Endif

There are other ways, but this will be quick and simple. Give it a try and
see if it works for you.
 
L

livin''''life

Now see, that is why I love this forum.

It worked beautifully. Thanks for the response.
 

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