listbox and 'All'

J

JohnE

I have a listbox on a form (lstA) that displays all the states. Another
listbox that will display any selected states (lstB) from lstA. At the top
of lstA is "All States". What the users are wanting is if they select "All
States" that all the states are then selected in lstA to be moved to lstB.
They do not want to select each individual state. However, the "All States"
does not move to lstB. Listbox lstA is set for multiselect.
How would I go about working this out? Any thoughts or suggestions welcomed.
*** John
 
J

Jeff Boyce

John

An alternate approach you could see if your users would accept...

Try out one of the "new" wizards - say, the new query wizard. When you get
to the step of selecting which fields to include, notice that there's an
">>" (all) button.

Could you adapt this for your situation, and let the users select one or
click the ">>" button to move all?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
J

JohnE

Jeff, that might just work. If I did that then I would not need 'All States'
at the top of the list. Do you know of an example I could look at?
Otherwise, thanks.
*** John
 
J

JohnE

Jeff, the more I look at that the more I think the users would go for it. So
thanks for the feedback. But by asking for an example was meant to assist me
in how to go about creating the code behind the buttons. That is the example
I was referring to. So, if you know of any samples/examples of something
like that, let me know. Otherwise, thanks again.
*** John
 
J

Jeff Boyce

John

The generic approach (pseudo-code - will not actually run):

* fill the first listbox using a query against the table that has all
possibles
* create a button that takes the one(s) selected in the listbox, and
* adds it/them to a new table - you can use a SQL statement like "INSERT
INTO ..."
* create a second button that ignores what's selected, but cycles through
every item in the first list, and
* adds it/them to the new table - "INSERT INTO..."

(* you might want to add a "Remove One" and "Remove All" button too - these
use "DELETE ...")

You'll need to work with the .ItemSelected property of the listbox, as well
as the collection of items in the listbox.

This is not a trivial exercise -- do you have a comfort level with creating
event procedures/code?

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
J

JohnE

Jeff, I do and don't have a comfort level. I say that as I can do somewhat
simpler tasks of coding but what you described, I would say I don't have a
comfort level. I am willing to live and learn new "tricks" and tips of
coding. I will give this a whirl and see where it takes me. I love a
challenge.
Thanks.
*** John
 

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