在我的一个表中有一个"组别"字段
里面的记录有学生,老师,家庭等多个记录,并且是可重复的
如何在combobox中添加这些记录为无重复的?

解决方案 »

  1.   

    在说SQL语句的时候就做判断例如:
    dim sql as string
    dim cn as new adodb.connection
    dim rs as new adodb.recordset
    dim i as long
    sql = "select distinct * from 组别" 'distinct 是取消重复的字段
    cn.open "连接字符串"
    rs.open sql,cn,4
    if rs.recordcount > 0 then
         do while rs.eof <> true
             combobox.additem trim(rs.fields(i).value)
             rs.movenext
         loop
    else
         msgbox "没有记录!"
    end if
    rs.close
    cn.close
    大哥求你件事情,~~~~如果解决问题,请及时结分`~~~OK?
      

  2.   

    使用SQL查询语句"select distinct 组别 from 表名"
    然后利用for循环将得到的记录字段值添加给combobox