烦请帮手看看:
Dim d As Date = e.Form.Controls("DateTimePicker1").value
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim dt1 As New Date(y, m, 1) '按月统计
Dim q As Integer = math.Ceiling(d.month / 3)'本面三行是季度条件
Dim dt2 As New Date(y, 3 * (q - 1) + 1, 1) '获取该季度的第一天
Dim dt3 As New Date(y, 3 * q, Date.DaysInMonth(2011,3 * q)) '获取该季度的最后一天
Dim w As Integer = Date.Today.DayOfWeek '算出今天是星期几, 这三行是周条件
Dim dt4 As Date = Date.Today.AddDays(-w) '获取本周的第一天
Dim dt5 As Date = Date.Today.AddDays(6 - w) '获取本周的最后一天
Dim dt6 As New Date(y, 1, 1) '本二行是日条件
Dim dt7 As New Date(y, 12, 31)
Dim filter As String = ""
DataTables("汇总").StopRedraw
DataTables("汇总").DataRows.Clear
For Each xh As String In DataTables("库存流水帐").GetValues("型号", "型号 is not null")
Dim ndr As DataRow = DataTables("汇总").AddNew
ndr("型号") = xh
filter = "型号 = '" & xh & "' and 时间 >= #" & dt1 & "# and 时间 < #" & dt1.AddMonths(1) & "#"
ndr("入库统计_本月累计入库") = DataTables("库存流水帐").Compute("sum(入库数量)", filter)
ndr("出库统计_本月累计出库") = DataTables("库存流水帐").Compute("sum(出库数量)", filter)
filter = "型号 = '" & xh & "' and 时间 >= #" & dt2 & "# and 时间 < #" & dt3.AddDays(1) & "#"
ndr("入库统计_本季累计入库") = DataTables("库存流水帐").Compute("sum(入库数量)", filter)
filter = "型号 = '" & xh & "' and 时间 >= #" & dt4 & "# and 时间 < #" & dt5 & "#"
ndr("入库统计_本周累计入库") = DataTables("库存流水帐").Compute("sum(入库数量)", filter)
filter = "型号 = '" & xh & "' and 时间 = #" & dt6 & "# and 时间 = #" & dt7 & "#"
ndr("入库统计_本日入库") = DataTables("库存流水帐").Compute("sum(入库数量)", filter)
Next
DataTables("汇总").ResumeRedraw
“本日入库”“与本周累计入库”,执行没结果,您看看是哪儿出了错了,