两个表“审批表”、“库存表”都是sql server 2008外部表 代码如下:
统计的时候如果加上时间限制就出现错误,如果两个表都是内部表就没问题,求高手指点,谢了!!!
(第二行代码显示不出来,我多加了几个空格)
Dim b As New SQLGroupTableBuilder("汇总表","审批表")
b.C o nnectio nN ame = "外链接1"
b.AddTable("审批表","器材编号","库存表","器材编号")
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If b.Filter >"" Then
b.Filter = b.Filter & " And "
End If
b.Filter = b.Filter & "日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If b.Filter >"" Then
b.Filter = b.Filter & " And "
End If
b.Filter = b.Filter & "日期 <= #" & .Value & "#"
End If
End With
b.Groups.AddDef("日期", DateGroupEnum.Year, "年度")
b.Groups.AddDef("日期", DateGroupEnum.Month, "月份")
b.Groups.AddDef("{审批表}.器材名称")
b.Totals.AddDef("库存数量")
b.Totals.AddDef("报废数量")
b.Subtotal = True '
Tables("数据汇总_汇总表").DataSource = b.BuildDataSource()
[此贴子已经被作者于2011-9-6 20:32:43编辑过]