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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox help 2

Status
Not open for further replies.

nat1967

Technical User
Feb 13, 2001
287
US
Hi,

I have two multi select list boxes on my form. I want the user to be able to select one or multiple items in the first listbox and move them to the second listbox.

Accomplished this with:

Dim ctl As Control
Dim varItm As Variant
Dim strVal As String
Set ctl = Me!listSysImpacted
For Each varItm In ctl.ItemsSelected
strVal = strVal & ctl.ItemData(varItm) & "; "
Next

ListSystemImpactedSelected.RowSourceType = "Value List"
ListSystemImpactedSelected.RowSource = strVal

Now, I'm stuck. What if the user wants to deselect an item from the second listbox. How can I remove one or multiple items from the second listbox if the user wants?

TIA

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Hi Nathan,

If you place the code above in the On Click event of listSysImpacted, when the user selects or de-selects an item, the selection will be reflected in ListSystemImpactedSelected each time.

If I've misinterepted what you're trying to do, please let me know.

Bill
 
Hi bill,

actually, getting everything over to ListSystemImpacted works. what i need to do is if something is populated in the ListSystemImpacted listbox and the user wants to remove it, the user can by selecting the item and clicking another command button to remove the item from ListSystemimpacted.

any thoughts?

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Hi Nathan,

I don't think that you understood me. If you add your code to the On Click Event, If the item hasn't already been selected then it will be added to ListSystemImpactedSelected, if it has already been selected, then it will be removed from ListSystemImpactedSelected. Basically, there is no need for a Command Button to Add or Remove Items.

If you go to you will find nathan1967.zip ready for download demonstrating what I mean.

Bill
 
You are correct. I didnt understand. I am stuck in "have to have command button" land. LOL....

Bill, thanks so much for helping me get past my mental challenge.

Have a great day!!! and a star too....

Have A Great Day!!!, [bigglasses]

Nathan
Senior Test Lead
 
Nice Code Bill Power. My hat goes off to you.

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top