Private Sub Combo1_Click()
List1.Clear
If cn.State = adStateOpen Then cn.Close
If rs.State = adStateOpen Then rs.Close
connstr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=PT_AS_DB;Data Source=ouyang-c19a8722."
conn.ConnectionString = connstr
conn.Open connstr
sql = "select * from WarehouseStockDetail "
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenDynamic, adLockPessimistic
'下面我没改你自己参考一下改改吧!
If rs.RecordCount > 0 Then
While Not rs.EOF
If rs.Fields(Combo1.Text) <> "" Then
Combo2.AddItem rs.Fields(Combo1.Text) & ""
End If
rs.MoveNext
Wend
End If
If Combo2.List(0) <> "" Then
Combo2.Text = Combo2.List(0)
End If
End Sub