你的主表和子表,是通过 入库单号 关联的,所以应该这样写
Select Case e.DataCol.Name
Case "存货编码","数量"
Dim drs As List(of DataRow)
Dim Filter As String
Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [存货编码] = '" & e.DataRow("存货编码") & "'"
drs = e.DataTable.Select(Filter)
For Each dr As DataRow In drs
Filter = "[_SortKey] <= " & dr("_SortKey") & " And [存货编码] = '" & dr("存货编码") & "' and [入库单号] = '" & e.DataRow("入库单号") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter)
dr("累计入仓数量") = Val1
Next
If e.DataCol.Name = "存货编码" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [存货编码] = '" & e.OldValue & "'"
drs = e.DataTable.Select(Filter)
For Each dr As DataRow In drs
Filter = "[_SortKey] <= " & dr("_SortKey") & " And [存货编码] = '" & dr("存货编码") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(数量)",Filter)
dr("累计入仓数量") = Val1
Next
End If
End Select
[此贴子已经被作者于2014-2-24 22:38:22编辑过]