|
以下不能运行,请老师指点一下,错在那里,具体见附件:
试验1.rar
(223.94 KB, 下载次数: 3)
Private Sub CommandButton3_Click()
Dim cnn As Object, rs As Object, SQL$, s$, i&, j&
Set cnn = CreateObject("ADODB.Connection")
cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName
SQL = "select * from [Sheet1$a:o] where 到龄月份 between #" & Trim(TextBox11.Value) & ""
If Len(ComboBox6.Value) Then SQL = SQL & " and 办理情况='" & ComboBox6.Value & ","
Set rs = cnn.Execute(SQL)
With ListView1
.ListItems.Clear
Do While Not rs.EOF
i = i + 1
.ListItems.Add , , rs.Fields(0).Value
For j = 1 To rs.Fields.Count - 1
.ListItems(i).SubItems(j) = rs.Fields(j).Value
Next
rs.MoveNext
Loop
End With
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub
|
|