PDA

View Full Version : Solved: list and combo box



joanna_gr
03-28-2005, 10:14 AM
Hi all. I hope you can help me on this. I have a list box with names (each name i repeated several times). I want to conbine this list box with a combo box so when I select a name in the combo box all same names in the list box are selected. Any help on this?:dunno

mdmackillop
03-28-2005, 11:04 AM
Hi Joanna,
Welcome to VBAX

Have a look at the attached example

joanna_gr
03-28-2005, 12:38 PM
works great. many many thanks!!!! :clap:

joanna_gr
03-29-2005, 04:40 AM
well, here I am again. As far as I'm running your example I get the results I want. If I try to build my own form then I get the following message "Run-time error 70, Permission Denied". Any idea what might goes wrong? :doh:

mdmackillop
03-29-2005, 05:22 AM
Check that your listbox is set to Multiselect in the properties window.
What line of code is highlighted when this error occurs?
Can you zip and post your document? Use Go Advance and Manage Attachments to do this.

joanna_gr
03-29-2005, 05:55 AM
ok. here is my attempt.

mdmackillop
03-29-2005, 11:09 AM
Hi Joanna,
I'm getting the same result. I'll investigate and get back to you.

joanna_gr
03-29-2005, 11:42 AM
ok thanks. please note that I need to show 2 columns in the list cause one holds names and the other holds surnames. If this is possible.

mdmackillop
03-29-2005, 12:26 PM
Hi Joanna,
The problem was cause by the setting of the list and combo box by both an Initialize sub and the rowsource property. Delete either and the form works fine. I've amended your code to delete the initialize macro.
Regarding the two names, I've added this to the sample. The listbox has to be set to two columns and the column containing the main data is set as the "Bound" column.
I've called the Names columns MyNames and set the RowSource accordingly.
If this requires to be dynamic, this can be set by your code when the workbook opens.

joanna_gr
03-29-2005, 09:11 PM
Well it seems that works now. I'll try it further. I need something else thought to complete my work. As you noticed i added some code to show the contents of the list box on the sheet. Is it possible to show both columns? This is important as I have to show the names/surnames and help a vlookup formula on the sheet to locate the other columns beside. Well I'm sure you can do another one miracle! : pray2: :)