老师,我用2楼的方式进行了代码测试后,红色代码统计出来的没有问题,但是结果还是不对,如图2。
Dim sql5 As String = "Sel ect * from 生产任务总表 as a5 where exists(sel ect * from 生产排产表 as b5 where " & Forms("生产排产表").controls("生产排产表").Table.DataTable.LoadFilter & " and a5.成品编码 = b5.成品编码 And a5.生产批次 = b5.生产批次 And a5.使用设备 = b5.使用设备 And a5.加工工序 = b5.加工工序 And a5.生产日期 >= '" & Format(Date.Today, "yyyyMMdd") & "' )"
Dim b5 As New Group TableBuilder("统计表5", sql5, "条码扫描系统数据库")
b5.Groups.AddDef("成品编码") '根据产品分组
b5.Groups.AddDef("生产批次") '根据产品分组
b5.Groups.AddDef("使用设备") '根据产品分组
b5.Groups.AddDef("加工工序") '根据产品分组
b5.Totals.AddDef("生产日期", AggregateEnum.Count, "剩余天数") '对生产日期进行统计
Dim dr22 As DataTable = b5.Build(True)
Dim dr32 As DataRow
For Each dr25 As Row In Tables("生产排产表_生产排产表").Rows
dr32 = dr22.find("成品编码 = '" & dr25("成品编码") & "' and 生产批次 = '" & dr25("生产批次") & "' and 使用设备 = '" & dr25("使用设备") & "' and 加工工序 = '" & dr25("加工工序") & "' and 生产日期 >= '" & Format(Date.Today, "yyyyMMdd") & "'")
If dr32 IsNot Nothing Then
dr25("剩余天数") = dr32("剩余天数")
End If
Next

此主题相关图片如下:2.jpg
