但是你的数据库的类型是字符型的,就不能用between了。
程序代码:Private Sub Command6_Click()
Dim LV1 As ListItem
Dim Sum As Long
ListView1.ListItems.Clear
Call OpenCNN
' SQL = "select * from 通讯录 where (填表日期 >= '" & DTPicker1.Value & "' and 填表日期 <='" & DTPicker2.Value & "') and 村组= '" & Combo7.Text & "'and 金额类型= '" & Combo6.Text & "'"
SQL = "select * from 通讯录 where (填表日期 >= '" & DTPicker1.Value & "' and 填表日期 <='" & DTPicker2.Value & "') "
If Combo6.Text <> "" Then SQL = SQL & " and 金额类型= '" & Combo6.Text & "'"
If Combo7.Text <> "" Then SQL = SQL & " and 村组= '" & Combo7.Text & "'"
RST.Open SQL, CNN, 1, 3
'On Error Resume Next
For i = 1 To RST.RecordCount
Set LV1 = ListView1.ListItems.Add()
LV1.Text = RST.Fields("流水单号") '第一列要用text属性。
LV1.SubItems(1) = RST.Fields("姓名") '这是第2列。
LV1.SubItems(2) = RST.Fields("金额")
LV1.SubItems(3) = RST.Fields("村组")
LV1.SubItems(4) = RST.Fields("金额类型")
LV1.SubItems(5) = RST.Fields("填表日期")
Sum = Sum + Val(RST.Fields("金额"))
RST.MoveNext
Next
StatusBar1.Panels.Item(4).Text = "当前页面金额为:【" & Sum & "】元"
RST.Close
CNN.Close
End Sub[此贴子已经被作者于2020-8-17 11:00编辑过]








