By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

how to add an item from one list box to another??

100+
P: 106
one listbox1 displays information from one table1, listbox2 displays information from another table2.
I want to add an item from listbox2 to listbox1 using a button. (table1 will be effected, table2 stays the same )

How can i do this.

please help?
Nov 20 '06 #1
Share this Question
Share on Google+
5 Replies


Expert 5K+
P: 8,435
one listbox1 displays information from one table1, listbox2 displays information from another table2.
I want to add an item from listbox2 to listbox1 using a button. (table1 will be effected, table2 stays the same )

How can i do this.

please help?
I'm not expert in this area, but I'd guess what you will need to do behind the button is copy the record from table2 to table1, then use "ReQuery" on listbox1.
Nov 20 '06 #2

100+
P: 106
I'm not expert in this area, but I'd guess what you will need to do behind the button is copy the record from table2 to table1, then use "ReQuery" on listbox1.
can you clarify this abit.

I have two list boxes.
Listbox1 holds some data from query of table1 for a particular selection of the combobox.
listbox2 holds also some data from table2 independant of any selection.

What I want is that when I select an item from listbox2 and hit the OK button, it should be displayed in the listbox1(appened), also those item should also be added into the table1 for that particular selction from combobox.

Can you help
Nov 22 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
can you clarify this abit.

I have two list boxes.
Listbox1 holds some data from query of table1 for a particular selection of the combobox.
listbox2 holds also some data from table2 independant of any selection.

What I want is that when I select an item from listbox2 and hit the OK button, it should be displayed in the listbox1(appened), also those item should also be added into the table1 for that particular selction from combobox.

Can you help
Tara you can't do this as listbox1 is based on a query. Normally to add something to a listbox you have to add it to the relevant table in the query. Then requery the listbox.

What are you trying to do and why is just as important as the physical action you are trying to code. Explaining that will get you a more accurate answer than I want to move something from one listbox to another. It's hardly ever that simple. So explain your thinking and we'll take it from there.

Mary
Nov 22 '06 #4

P: 1
For i = 0 To lst1.ListCount - 1
If lst1.Selected(i) Then
lst2.AddItem lst1.Column(0)
End If
Next i
Dec 22 '06 #5

Expert 5K+
P: 8,435
For i = 0 To lst1.ListCount - 1
If lst1.Selected(i) Then
lst2.AddItem lst1.Column(0)
End If
Next i
Hi andy. Just a quick tip on posting, for future reference. If you want the indenting to work (it can be really frustrating the way it just disappears, huh), you have to put [c o d e] tags around your code. Like this...
Expand|Select|Wrap|Line Numbers
  1. For i = 0 To lst1.ListCount - 1
  2.   If lst1.Selected(i) Then
  3.     lst2.AddItem lst1.Column(0)
  4.   End If
  5. Next i
Dec 23 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.