Private Sub Command1_Click()
mydate1 = Left(Format(DTPicker2.Value, "short date"), 4) + Right(Left(Format(DTPicker2.Value, "short date"), 7), 2) + Right(Format(DTPicker2.Value, "short date"), 2)
mydate2 = Left(Format(DTPicker3.Value, "short date"), 4) + Right(Left(Format(DTPicker3.Value, "short date"), 7), 2) + Right(Format(DTPicker3.Value, "short date"), 2)
If Val(mydate1) > Val(mydate1) Then
MsgBox "起始時間不能大于結束時間", , "資訊提示"
DTPicker2.SetFocus
Exit Sub
Else
Adodc3.RecordSource = "select*from yongjin where 開戶時間 between'" + Str(DTPicker2.Value) + "'and'" + Str(DTPicker3.Value) + "'order by 開戶時間"
Adodc3.RecordSource = "select*from yongjin where 開戶時間>'" + Str(DTPicker2.Value) + "'and 開戶時間<'" + Str(DTPicker3.Value) + "'order by 開戶時間"
Adodc3.Refresh
Set DataGrid1.DataSource = Adodc3
End If
Adodc3.RecordSource = "select sum(金額) as 金額 from yongjin where format(開戶時間,'yyyy-mm-dd')>'" + Str(DTPicker2.Value) + "'and format(開戶時間,'yyyy-mm-dd')<'" + Str(DTPicker3.Value) + "'"
Adodc3.Refresh
On Error Resume Next
If Adodc3.Recordset.RecordCount > 0 Then
Lbl_Total = Adodc3.Recordset.Fields(0)
Else
Lbl_Total.Caption = 0
End If
End Sub
上面這段是查找一個時間段的資料,并匯總金額,但是只能顯示現行,求大神
Private Sub Command3_Click()
If Combo1.Text = "" Then
MsgBox "請選擇要查詢的月份", , "資訊提示"
Combo1.ListIndex = 0
Combo1.SetFocus
Exit Sub
Else
Adodc3.RecordSource = "select sum(金額) as 金額 from yongjin where format(開戶時間,'yyyy-mm')='2013-' + '" + Trim(Combo1.Text) + "'"
Adodc3.Refresh
On Error Resume Next
If Adodc3.Recordset.RecordCount > 0 Then
Lbl_Total = Adodc3.Recordset.Fields(0)
Else
Lbl_Total.Caption = 0
End If
Adodc3.RecordSource = "select (金額) as 金額,format(開戶時間,'yyyy-mm')as 開戶時間 from yongjin" & " where format(開戶時間,'yyyy-mm')='2013-' + '" + Trim(Combo1.Text) + "'group by 用戶姓名,服務帳號,format(開戶時間,'yyyy-mm')"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount > 0 Then
Lbl_Count = Adodc3.Recordset.RecordCount
Else
Lbl_Count = 0
End If
Set DataGrid1.DataSource = Adodc3
End If
End Sub
這段是查某個月份的,也是一樣的,但顯示錯誤
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/130484.html
上一篇:webQQ二次登錄回傳出錯的問題
