|
Private Sub CommandButton2_Click()
Dim cnn, rs, Sql$, s$, M&
Set cnn = CreateObject("ADODB.Connection")
Set rs = CreateObject("adodb.Recordset")
If ComboBox1 = "" Then Exit Sub
s = ComboBox1
cnn.Open "provider=microsoft.ace.oledb.12.0;data source=" & ThisWorkbook.Path & "\DA.mdb"
Sql = "select username,userduties from UserTable where username='" & s & "'"
rs.Open Sql, cnn, 1, 1
[A:A] = ""
M = 2
Do While Not rs.EOF
Cells(M, 1) = rs.Fields(0)
Cells(M + 1, 1) = rs.Fields(1)
M = M + 1
rs.MoveNext
Loop
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub
|
评分
-
1
查看全部评分
-
|