How to link a Visual Basic 6 Combo box with a fiel

2019-06-07 04:06发布

问题:

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.

Thanks

回答1:

 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