我的目标是
COMBO1通过查询到产品表中得到产品名称,然后COMBO2根据COMBO1里面的产品名称搜索出对应的产品型号类型并只在COMBO2中显示COMBO1中产品名称才有的产品型号我现在的问题是COMBO1里面把所有的产品名称都列出来了,我想把里面名称相同的只显示一个记录,怎么剔除相同的字符啊?我的产品表包括产品名称,产品型号,一个产品名称可以有多个型号,每一个产品名称和型号共同组合对应唯一的编号

解决方案 »

  1.   

    select distinct 产品名称 from tablename
      

  2.   

    在添加combobox数据的时候做个判断就好了
    Dim i As Integer
    dim flag as Boolean
    flag = True
    for i = 0 to Combo1.ListCount-1
        if 要添加的数据 = combo1.list(i) then
            flag =False
        end if
    next i
    if flag then
        Combo1.AddItem "第一条"
    end if
      

  3.   

    这样:private sub form_load()
    '填充 combo1
    set rs=cn.execute "select distinct 产品名称 from tablename order by 产品名称"
    do until rs.eof
        combo1.additem rs!产品名称
        rs.movenext
    loop
    if combo1.listcount then combo1.listindex = 0
    end subprivate sub combo1_click()
    '重新填充 combo2
    set rs=cn.execute "select 产品类型 from tablename where 产品名称='" & combo1.list(combo1.listindex) & "' order by 产品类型"
    combo2.clear
    do until rs.eof
        combo2.additem rs!产品类型
        rs.movenext
    loop
    if combo2.listcount then combo2.listindex = 0
    end sub
      

  4.   

    借这个帖 顺便问一下怎么才能限制combo输入文字,
    只能从下拉框里选择呢? 想让程序只选择我提供的数据 不要自己填入新的数据
      

  5.   

    Combo1.Style = 2 - DropDown