看楼主的要求
最简单的方法是将combobox绑定到一个记录集的员工姓名字段上。
blnInFind=false
sub Combo1_change()
if blnInFind=true then exit sub
blnInFind=true
rs.filter=""
rs.filter="员工姓名 like '%" combobox.text & "' "
'刷新combo,这个很久没有用你试试
combo1.refresh
blnInfind=false
end sub
try:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Combo1_Change()
combox1.Clear
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim iStart As Integer
Dim sString As String
Static iLeftOff As Integer
'cnn.Open ........ ' add your connectionstring
rst.Open "select DISTINCT [NAME] from employee where [NAME] like '" & Trim(combo1.Text) & "'%", cnn, 3, 3
Do While Not rst.EOF
combox1.AddItem rst.fields(0).Value
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set cnn = Nothing
iStart = 1
iStart = combo1.SelStart
If iLeftOff <> 0 Then combo1.SelStart = iLeftOff: iStart = iLeftOff
private sub combox1_change()
dim rs as adodb.recordset
...
combox1.clear
rs.open "select * from employeetable where employeename like '" & combox1.text & "'"
do while not rs.eof
combox.additem rs.fields(x).value
rs.next
loop
rs.close
set rs=nothing
...
end sub