呵呵,老兄你应该看一下帮助才开始改啊。
错误提示,出现死循环,你直接将计算代码移到DataColChanged事件中,任何一列的变化都会触发此事件,然后此事件又导致其他列发生变化,如此循环,自然出错。
最好这样改一下:
If e.DataCol.Name = "日期" Orlse e.DataCol.Name = "矿点" Then
Select Case vars("HZ")
Case
1
'按日期汇总按扭
e.DataRow("一车间_车数") = DataTables("明细表").Compute("sum(车数)", "[日期] = '"
&
e.Datarow("日期") &
"' and [车间] = '一车间'")
e.DataRow("一车间_毛重") = DataTables("明细表").Compute("sum(毛重)", "[日期] = '"
&
e.Datarow("日期") &
"' and [车间] = '一车间'")
e.DataRow("一车间_净重") = DataTables("明细表").Compute("sum(扣杂)", "[日期] = '"
&
e.Datarow("日期") &
"' and [车间] = '一车间'")
Case
2 '按全部矿点分日期汇总按扭
e.DataRow("一车间_车数") = DataTables("明细表").Compute("sum(车数)", "[矿点] = '"
&
e.Datarow("矿点") &
"' and [车间] = '一车间'and [日期] >= '"
&
vars("date0") &
"' and [日期] <= '"& vars("date1") &
"' ")
e.DataRow("一车间_毛重") = DataTables("明细表").Compute("sum(毛重)", "[矿点] = '"
&
e.Datarow("矿点") &
"' and [车间] = '一车间' and [日期] >= '"
&
vars("date0") &
"' and [日期] <= '"& vars("date1") &
"' ")
e.DataRow("一车间_净重") = DataTables("明细表").Compute("sum(扣杂)", "[矿点] = '"
&
e.Datarow("矿点") &
"' and [车间] = '一车间' and [日期] >= '"
&
vars("date0") &
"' and [日期] <= '"& vars("date1") &
"' ")
End Select
End If
[此贴子已经被作者于2008-12-10 12:00:24编辑过]