以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]按钮跨表引用问题?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=54038)

--  作者:jk362223
--  发布时间:2014/7/20 21:37:00
--  [求助]按钮跨表引用问题?
若有二表“表A”,"表B",一个按钮,现从 表A全部引用到 表B,要在 按钮上设置代码完成, 代码是如何写?请帮我
--  作者:有点甜
--  发布时间:2014/7/20 21:40:00
--  

 是引用,还是填充?

 

 填充,参考 http://www.foxtable.com/help/topics/0680.htm

 


--  作者:有点甜
--  发布时间:2014/7/20 21:43:00
--  

 引用的话,参考代码

 

 For Each dr As DataRow In DataTables("表B").DataRows
    Dim fdr As DataRow = DataTables("表A").Find("第一列 = \'" & dr("第一列") & "\'")
    If fdr IsNot Nothing Then
        dr("第二列") = fdr("第二列")
        dr("第三列") = fdr("第三列")
    End If
Next


--  作者:jk362223
--  发布时间:2014/7/20 22:06:00
--  
Dim nmc() As String = {"身份证号","姓名","性别","年龄","标识","县"} \'A表数据来源列
Dim nmd() As String = {"身份证号","姓名","性别","年龄","标识","县"} \'B表数据接收列
Dim dra As Row = Tables("名单").Current
Dim drc As Row = Tables("疾病证明书").AddNew
For i As Integer = 0 To nmc.Length - 1
    drc(nmd(i)) = dra(nmc(i))
Next 
这是二个表多列引用,现是要全部引用,怎样写?

--  作者:有点甜
--  发布时间:2014/7/20 22:08:00
--  
Dim nmc() As String = {"身份证号","姓名","性别","年龄","标识","县"} \'A表数据来源列
Dim nmd() As String = {"身份证号","姓名","性别","年龄","标识","县"} \'B表数据接收列
For Each dra As DataRow In DataTables("名单").DataRows
    Dim drc As Row = Tables("疾病证明书").AddNew
    For i As Integer = 0 To nmc.Length - 1
        drc(nmd(i)) = dra(nmc(i))
    Next
Next

--  作者:jk362223
--  发布时间:2014/7/20 22:20:00
--  
Dim nmc() As String = {"身份证号","姓名","性别","年龄","标识","县"} \'A表数据来源列
Dim nmd() As String = {"身份证号","姓名","性别","年龄","标识","县"} \'B表数据接收列
For Each dra As DataRow In DataTables("名单").DataRows
    Dim drc As Row = Tables("报销名单").AddNew
    For i As Integer = 0 To nmc.Length - 1
        drc(nmd(i)) = dra(nmc(i))
    Next
Next

除了这些列,还有好多列,有30多列,写起来麻烦,这二个表,基本相同,要怎样通过按钮边完成?

--  作者:有点甜
--  发布时间:2014/7/20 22:22:00
--  
 只有引用全部列,而且全部列相同,才能不写列名。
--  作者:jk362223
--  发布时间:2014/7/20 22:23:00
--  
是啊,就是这样作用,怎写?
--  作者:有点甜
--  发布时间:2014/7/20 22:24:00
--  
For Each dra As DataRow In DataTables("名单").DataRows
    Dim drc As Row = Tables("报销名单").AddNew
    For Each dc As DataCol In DataTables("名单").DataCols
        drc(dc.name) = dra(dc.name)
    Next
Next