Visual Basic 6:组合框,Adodc,Access 2010 [英] Visual Basic 6: Combo Boxes, Adodc, Access 2010

查看:87
本文介绍了Visual Basic 6:组合框,Adodc,Access 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个表的组合框中添加数据.我能够做到.然后,我想将那个组合框中的数据保存到另一个表中.我不能那样做.

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?

推荐答案



假设您使用与表关联的ADODC控件(假设其名称为mytable,并且名称f ADODC控件的名称为myadodc).然后,您可能会使用以下代码:

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:

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:

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!


这篇关于Visual Basic 6:组合框,Adodc,Access 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆