DataColChanged事件
Select Case e.DataCol.name
Case "单位名称", "年度", "月份"
If e.DataRow.IsNull("单位名称") = False AndAlso e.DataRow.IsNull("年度") = False AndAlso e.DataRow.IsNull("月份") = False Then
Dim d As Date = new Date(e.DataRow("年度"), e.DataRow("月份"), 1)
Dim filter As String = "采购单位 = '" & e.DataRow("单位名称") & "' and 采购日期 >= #" & d & "# and 采购日期 < #" & d.AddMonths(1) & "#"
e.DataRow("后备_进货") = DataTables("采购单明细").Compute("sum(数量)", filter)
Else
e.DataRow("后备_进货") = Nothing
End If
End Select