Foxtable(狐表)用户栏目专家坐堂 → 关联表复制到另一个关联表报错


  共有3898人关注过本帖树形打印复制链接

主题:关联表复制到另一个关联表报错

帅哥哟,离线,有人找我吗?
lgz518
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8549 威望:0 精华:0 注册:2019/6/13 9:57:00
关联表复制到另一个关联表报错  发帖心情 Post By:2021/10/28 0:01:00 [只看该作者]

需求: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


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/10/28 8:47:00 [只看该作者]

For Each dr3 As DataRow In DataTables("A明细").Select("[选中] = 1 ")
    Dim dr4 As Row = Tables("B主表.B明细").AddNew()
    For r As Integer = 0 To Cols3.Length -1
        dr4(Cols4(r)) = dr3(Cols3(r))
    Next
        
Next

 回到顶部