要重置表C消耗列。如果要重置日期列,改改代码
Select Case e.DataCol.name '非关联表间的数据同步 表A同步表C
Case "日期"
If e.OldValue <> Nothing Then
Dim dr As DataRow = DataTables("表A").Find("日期 = #" & e.OldValue & "#")
If dr Is Nothing Then
dr = DataTables("表A").AddNew()
End If
dr("日期") = e.DataRow("日期")
dr("数量") = e.DataRow("消耗")
Else
Dim dr As DataRow = DataTables("表A").Find("日期 = #" & e.newValue & "#")
If dr Is Nothing Then
dr = DataTables("表A").AddNew()
End If
dr("日期") = e.DataRow("日期")
dr("数量") = e.DataRow("消耗")
End if
Case "消耗"
Dim dr As DataRow = DataTables("表A").Find("日期 = #" & e.DataRow("日期") & "#")
If dr IsNot Nothing Then
dr("数量") = e.DataRow(e.DataCol.Name)
End If
End Select
另外不同行不能有重复的日期值,因为不知道要更新哪一行