我贴上来的代码是控制向combox中添加不重复记录的,如果要添加的记录在列表中已经存在则不添加,应该对你有所帮助Public Sub AddToCombX(CombX As ComboBox, sAdd As String)
    Dim iRet As Integer
    iRet = SendMessageFind(CombX.hwnd, CB_FINDSTRING, 0, sAdd)
    If iRet = CB_ERR And Trim(sAdd) <> "" Then
        CombX.AddItem sAdd, 0
    End If
End Sub至于从数据库中读取并显示不重复记录,你可以通过判断来完成,如果在列表中有这个名称记录了就不添加即可。可以输入也可以选择的combox,可以将其style属性设置为0(其实这是默认值)

解决方案 »

  1.   

    打开记录集时要使用"Select Distinct..."
      

  2.   

    比如:Select Distinct(客户名) From 表
      

  3.   

    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=表名;Persist Security Info=False"
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select distinct(客户名) from 表名"这样就行了!
      

  4.   

    Select Distinct(dd) From Table
    Select dd From Table  group by dd
      

  5.   

    Use "SELECT DISTINCT [FieldName] FROM [Table]" to return only distinctive records.
      

  6.   

    Select Distinct(客户名) From Table
      

  7.   

    dim i as integer
    dim iflike as boolean
    iflike=false
    adodc1.recordset.movefirst
    while not adodc1.recordset.eof
        for i=0 to combox.listcount-1    
           if adodc1.recordset!客户名=combox.list(i) then  iflike=true    
        next
        if iflike=false then combox.additem adodc1.recordset!客户名
        iflike=false
    wend