Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate one listbox with selection from another listbox

Status
Not open for further replies.

henley12

Programmer
Mar 26, 2004
17
0
0
US
I have a form with two listboxes. The left listbox needs to be populated with data from the right listbox. The data in the right listbox needs to look like the following:

Heading1
value1
value2
value3

Heading2
value4
value5

...etc.

First, is it possible to populate a listbox to look like the above. Second, how do I make it so I can double-click an item in the right listbox and add to the left listbox? Help would be most appreciated. Thanks.
 
Have a look here:
faq702-6326

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I have seen that article. I have the process of switching them from one listbox to the other working (except I want it to add to the left listbox and not remove the entry from the right listbox. When I double-click the left listbox, I just want it to delete from the listbox, not necessarily add it back to the right one). Any ideas on how to format a list box similar to the above example.....with headings and spaces?
 
If I was to format a value list to look like that I would dynamically create the value list probably reading from a recordset:

on the form on load event

some code to build a string...
final string to look something like:
strList = "CARS;- Ford;- Chevy;- Honda;MOTORCYCLES;- Yamaha;- Suzuki"
Me.List0.RowSource = strList

this output would look like this

CARS
- Ford
- Chevy
- Honda
MOTORCYCLES
- Honda
- Suzuki

Then on my on click event, I would have some code to see if the value begins with "-", if it does strip two characters off the left and return the value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top