就应该使用统计工具呀:http://www.foxtable.com/webhelp/topics/1623.htmDim dr As DataRow = Args(0)
Dim g As New GroupTableBuilder("统计表1", DataTables("生产过程进度追溯表"))
g.FromServer = True
g.Groups.AddDef("备用2")
g.Totals.AddDef("投料数量")
g.Totals.AddDef("入库数量")
……
g.filter = "备用2 = '" & dr("销售计划号") & "'"
dim dt as datatable = g.Build(true)
dim dr2 as datarow = dt.datarows(0)
dr("投料数量") = dr2("投料数量")
dr("入库数量") = dr2("入库数量")……