给你一段代码,看你能否看懂,看不懂再说
Sub Combox_AddItem(P_Form_Control As Object, P_Feild As String, P_Record_Name As String, Optional p_sql As String)
Dim W_Rb As New ADODB.Recordset
Dim W_Sql As String
W_Sql = "Select distinct " & P_Feild & " as Tmp_Feild From " & P_Record_Name & " Where isnull(" & P_Feild & ",'')<>''" & p_sql & " ORDER BY " & P_Feild
P_Form_Control.Clear
'常用人员名单
With W_Rb
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.ActiveConnection = G_Con
.Open W_Sql
End With
While W_Rb.EOF <> True
P_Form_Control.AddItem W_Rb!Tmp_Feild
W_Rb.MoveNext
Wend
W_Rb.Close
Set W_Rb = Nothing
End Sub