需求:A主表,A明细是关联表,批量复制B主表和B明细是关联表,
在窗口上-按键-执行下代码,
1.不执行红字代码,是可以分表复制,但B主表和B明细是关联表,B明细关联表无数据,B明细无关联表有数据?
2,执行红字代码,执行不了
Dim Cols1() As String = {"订货日期","客户名称"}
Dim Cols2() As String = {"日期","客户"}
For Each dr1 As DataRow In DataTables("A主表").Select("[选中] = 1 ")
Dim dr2 As DataRow = DataTables("B主表").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
Dim Cols3() As String = {"产品编号","产品名称","数量","单位"}
Dim Cols4() As String = {"存货编码","存货名称","数量","单位"}
For Each dr3 As DataRow In DataTables("A明细").Select("[选中] = 1 ")
Dim dr4 As DataRow = DataTables("B明细").AddNew()
'Dim dr4 As DataRow = DataTables("B主表.B明细").AddNew()
For r As Integer = 0 To Cols3.Length -1
dr4(Cols4(r)) = dr3(Cols3(r))
Next
Next