Dinghus
Aug 16 2006, 01:37 PM
I have a combobox and a listbox. The cbo is the 1 and the listbox is the many. But how can I make a selection in the cbo and have the corresponding items highlighted (selected) in the listbox?
kbrewster
Aug 16 2006, 01:45 PM
Do a search on this site for cascading combo. There are many examples here. Also check out Candace Tripps website:
http://www.candace-tripp.com/pages/access_downloads.aspx
ScottGem
Aug 16 2006, 01:47 PM
Why would you want to do this? I can understand listing the corresponding items inthe list box, but what value does selecting them give you? wouldn't it be easier to just use a query that filters for the combo selection?
Dinghus
Aug 16 2006, 01:54 PM
Here is why I or anybody else would want to do this.
Say you have in the cbo the list of depts in the company. In the listbox would be all the employees in the company. So you select a dept in the cbo and all the employees in that dept are highlighted (selected). Now I can DESELECT some or SELECT more. In other words add to or take away from the dept roster.
This is very basic functionality for an HR type application. It is much easier than having to select each employee individually and setting the dept they are in.
Dinghus
Aug 16 2006, 02:02 PM
Hmmmm Cascading isn't what I want to do either. That is fairly easy.
In a nutshell, how do I automatically multi-select in a listbox based on a cbo selection? The other access coworkers etc say it is impossible. So I'm checking.
ScottGem
Aug 16 2006, 03:04 PM
Actually, as someone who has written an HRIS application this is not as basic as you seem to think it is. Generally employees are selected based on common criteria.
However, there is a way you may be able to do this. Search on fkegley and Multi-select listbox. He has a sample file that allows you to move selections in a listbox into another, selected listbox. You should be able to adapt the code to move people from the delected Department iunto the selected listbox. Then either remove or add to that list.
fkegley
Aug 16 2006, 03:06 PM
Well one way would be with some code immediately following the setting of the Row Source.
Me.ListBox1.RowSource = "whatever the Row Source is goes here"
For I = 0 to Me.ListBox1.ListCount - 1
Me.ListBox1.Selected(I) = True
Next I
I have attached the database that Scott referred to.
Edited by: fkegley on Wed Aug 16 16:10:21 EDT 2006.
Dinghus
Aug 16 2006, 03:15 PM
Well, Scott, I won't argue about how common it is, since I've written about a dozen in other programming environments, but, believe me, if nothing else it makes your life a whole lot easier to do it this way.
Ahhh. Frank. That maybe what I need. I had locked in on ItemsSelected. Have to try and see if just Selected will work. It should now that the obvious is pointed out.
fkegley
Aug 16 2006, 03:18 PM
You're welcome. I am glad I could help.
Dinghus
Aug 16 2006, 03:23 PM
I'd give you a hug and kiss but that just isn't manly so I'll just o!

instead.
I always love being shown the obvious. Really keeps me humble. LOL
Dinghus
Aug 16 2006, 03:49 PM
Now if you could just tell me how to make them a different color. Black and white is so boring.
fkegley
Aug 16 2006, 04:08 PM
Email me a cold Foster's instead.
You're welcome. I am glad I could help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.