以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何写表a到表b提值的代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=133076)

--  作者:jcaigen
--  发布时间:2019/4/5 23:19:00
--  如何写表a到表b提值的代码
如何写表a到表b提值的代码
--  作者:有点蓝
--  发布时间:2019/4/6 10:51:00
--  
请不要重复发帖:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=133075
--  作者:jcaigen
--  发布时间:2019/4/7 11:26:00
--  

如何写表a取值列到表b提值的代码

表a

 编码    表B列名    取值  
   001    列a    
   001   列a    
   001    列a    
   002    列b    
   002    列b    
   002    列b    
   003    列c    
   003    列c    
   003    列c    

表b

 

  编码   列a     列b   列 c 
   001  值1     值2    值3
   002  值4      值5    值6
   003  值7    值8    值9
               

--  作者:有点甜
--  发布时间:2019/4/7 12:09:00
--  

Dim fdr As DataRow = DataTables("表B").find("编码=\'" & e.DataRow("编码") & "\'")

If fdr IsNot Nothing Then

    msgbox("找到")

    If fdr.DataTable.datacols.contains(e.DataRow("表B列名")) Then

        msgbox(2)

        e.DataRow("取值") = fdr(e.DataRow("表B列名"))

    Else

        msgbox(1)        

        e.DataRow("取值") = Nothing

    End If

End If