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

moving selected items in a listbox

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I am trying to move items from a listbox called lstavapps to a listbox called lstinapps. I am populating the lstavapps by a query from a table. My code is below. The problem I am having is when it adds them to the lstinapps it just adds the row #'s, i.e: 0,1,2,3, etc.. I want to add the actual string.

Private Sub cmdAdd_Click()

Dim ctlList As Control, varItem As Variant
Set ctlList = Forms!frmServers!lstavapps

For Each varItem In ctlList.ItemsSelected
Dim additem As String
lstinapps.additem (varItem)

Next varItem


End Sub
 
Perhaps this ?
For Each varItem In ctlList.ItemsSelected
lstinapps.additem ctlList.ItemData(varItem)
Next varItem

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,

This code still just adds number rows and not the string.

 
It seems that your listbox has more than one column. I am puzzled by AddItem in VBA, so this is just a rough idea:

[tt]ctlList.Column(1, varItem)[/tt]
 
So did you try the Column property, as illustrated?
 
that worked. however it will not save it to the database for some reason. I have the field setup as a Memo field. When it adds it it will not save it to the database and when I cycle to the next record it does not clear the values stay the same in the lstinapps list box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top