需求;汇总表A的"单号、品名、规格、完成数",执行下面代码,没有报错,没提示,如何处理?
If e.DataCol.Name = "单号" AndAlso e.DataCol.Name = "品名" AndAlso e.DataCol.Name = "规格" Then '发生变化的是XX单号列
Dim Filter As String = "[单号] = '" & e.NewValue & "' AND [品名] = '" & e.NewValue & "' AND [规格] = '" & e.NewValue & "'"
e.DataRow("完成数") = DataTables("表B").Compute("Sum(完成数)", Filter)
' MsgBox(10)'排查错
msgbox(Filter) '调试用
End If
先学好基础:
http://www.foxtable.com/webhelp/topics/0220.htm
If e.DataCol.Name = "单号" OrElse e.DataCol.Name = "品名" OrElse e.DataCol.Name = "规格" Then '发生变化的是XX单号列
Dim Filter As String = "[单号] = '" & e.NewValue & "' AND [品名] = '" & e.NewValue & "' AND [规格] = '" & e.NewValue & "'"
这里三个条件的新值,只有一个新值。执行提示:[单号]="'QT*20"AND [品名] = "'QT*20"AND [规格] = "'QT*20"
很明显查询条件里有多余的空格,其次三个列都查询同样的数据,有符合这个条件的数据?
要知道e.NewValue表示的是当前正在录入的这个单元格的值,而不是表示3个列的单元格值,所以确定不应该是这样?
Dim Filter As String = "[单号] = '" & e.DataRow("单号") & "' AND [品名] = '" & e.DataRow("品名") & "' AND [规格] = '" & e.DataRow("规格") & "'"