如何将Visual Basic 6组合框与Microsoft Access 2007表中的字段链接 [英] How to link a Visual Basic 6 Combo box with a field in a Microsoft Access 2007 Table

查看:193
本文介绍了如何将Visual Basic 6组合框与Microsoft Access 2007表中的字段链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Microsoft Access 2007中有一个教师表。我想获得教师的所有名字从字段Tch_name到VB6中的组合框列表。是否需要创建循环?任何人都可以帮助我。

There is a Teacher Table in Microsoft Access 2007. And i want to get all the names of the Teachers from the field Tch_name to a combo box list in VB6. Does a loop needs to be created? Can anyone help me out please.

感谢

推荐答案

 dim db as new adodb.connection

    'then open your database with db connection
    dim r as new adodb.recordset
    r.open "select Name from Teacher", db, adopendynamic, adlockoptimistic, adcmdtext

    'I guess column name is Name
    do while not r.eof
        combo1.additem(r.fields(0))
        r.movenext
    loop

这篇关于如何将Visual Basic 6组合框与Microsoft Access 2007表中的字段链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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