Private Sub DTPicker1_Change()
ListView1.ListItems.Clear
ListView2.ListItems.Clear
ListView1.Refresh
ListView2.Refresh
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim cmd1 As New ADODB.Command
Dim rs1 As New ADODB.Recordset
Call ConToSQLDB
cmd.ActiveConnection = sqlcon
cmd.CommandText = "select 日期,左胎号,机台号 from barcode" & Format(Date, "yyyy") & " where 日期 between '" & Format(DTPicker1 - 1, "yyyymmdd") & "' and '" & Format(DTPicker1, "yyyymmdd") & "' group by 日期,左胎号,机台号 having count(左胎号)>1"
Set rs = cmd.Execute
i = 1
While Not rs.EOF
ListView1.Refresh
ListView1.ListItems.Add
ListView1.ListItems(i).Text = rs(0).Value
ListView1.ListItems(i).SubItems(1) = rs(1).Value
ListView1.ListItems(i).SubItems(2) = rs(2).Value
i = i + 1
rs.MoveNext
Wend
Label4.Caption = i - 1
cmd1.ActiveConnection = sqlcon
cmd1.CommandText = "select 日期,右胎号,机台号 from barcode" & Format(Date, "yyyy") & " where 日期 between '" & Format(DTPicker1 - 1, "yyyymmdd") & "' and '" & Format(DTPicker1, "yyyymmdd") & "' group by 日期,右胎号,机台号 having count(右胎号)>1"
Set rs1 = cmd1.Execute
m = 1
While Not rs1.EOF
ListView2.Refresh
ListView2.ListItems.Add
ListView2.ListItems(m).Text = rs1(0).Value
ListView2.ListItems(m).SubItems(1) = rs1(1).Value
ListView2.ListItems(m).SubItems(2) = rs1(2).Value
m = m + 1
rs1.MoveNext
Wend
Label6.Caption = m - 1
rs.Close
rs1.Close
sqlcon.Close
End Sub