A表是包含四个项目时间数据的总表,BCDE表是按照四个不同项目时间划分的子表。
如何实现在A表新增一条数据,这条数据根据项目时间的不同,自动更新到对应的BCDE表上
而且当在A表删除这条数据的时候,
BCDE表上对应的这条数据也会自动删除。
自己试了很多次都没有成功,请教下论坛上的高手们该怎么办。
For Each dr1 As DataRow In DataTables("A").Select("[项目时间] = 'B'")
Dim dr2 As DataRow = DataTables("testB").AddNew()
For Each dc As DataCol In DataTables("A").DataCols
dr2(dc.Name) = dr1(dc.name)
Next
Next
For Each dr1 As DataRow In DataTables("A").Select("[项目时间] = 'C'")
Dim dr2 As DataRow = DataTables("testC").AddNew()
For Each dc As DataCol In DataTables("A").DataCols
dr2(dc.Name) = dr1(dc.name)
Next
Next
For Each dr1 As DataRow In DataTables("A").Select("[项目时间] = 'D'")
Dim dr2 As DataRow = DataTables("testD").AddNew()
For Each dc As DataCol In DataTables("A").DataCols
dr2(dc.Name) = dr1(dc.name)
Next
Next
For Each dr1 As DataRow In DataTables("A").Select("[项目时间] = 'E'")
Dim dr2 As DataRow = DataTables("testE").AddNew()
For Each dc As DataCol In DataTables("A").DataCols
dr2(dc.Name) = dr1(dc.name)
Next
Next
也有在DataColChanged上设置上有新增的会自动更新,但是不会设置DataRowDeleting