Click here to Skip to main content
15,891,926 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to add data in a combo box from one table. I am able to do so. Then I want to save the data in that combo box to another table. I am not able to do that. How do I do it?
Posted
Comments
Sandeep Mewara 24-Jun-12 15:16pm    
It would help you more if you share the related code where you are stuck.
[no name] 24-Jun-12 15:50pm    
What do you mean "I am not able to do that"? Of course you are able to do it. What have you tried that did not work?
Sergey Alexandrovich Kryukov 24-Jun-12 17:05pm    
Good point!
--SA
ZurdoDev 25-Jun-12 9:06am    
You need to write code to do it. Please get started and let us know where you get stuck.

1 solution

Hi,

Suppose you use an ADODC control that is associated with your table(suppose its name mytable, and suppose that the name f ADODC control is myadodc). Then u might eb using such code:

VB
myadodc.Recordset.MoveFirst
Do Until myadodc.Recordset.EOF
mycombobox.AddItem (myadodc.Recordset.Fields("Desired column_name"))
myadodc.Recordset.MoveNext
Loop


Then to save data to another table from this combo box, you should do this:
VB
mycombobox.listindex = 1
do until mycombobox.listindex = mycombobox.listcount
myadodc.recordset.addnew
myadodc.recordset.fields("colum_name") = "column value"
myadodc.recodset.update
mycombobox.listindex = val(mycombobox.listindex) + 1
loop

Hope this helps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900