以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关联表的同步更新  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=58950)

--  作者:newsun2k
--  发布时间:2014/10/27 11:24:00
--  关联表的同步更新
主表:A,B,C,D,E,F,G
子表:A,B,C,M,K,L
主表和子表通过A关联,希望主表的B,C更新时,子表同步更新,如何实现?
子表的B和C有可能单独更新,因而不能用表达式列

--  作者:有点甜
--  发布时间:2014/10/27 11:26:00
--  

 参考教程

 

http://www.foxtable.com/help/topics/2490.htm

 


--  作者:Bin
--  发布时间:2014/10/27 11:26:00
--  
http://www.foxtable.com/help/topics/1453.htm
--  作者:有点甜
--  发布时间:2014/10/27 11:28:00
--  

datacolchanged代码

 

If e.DataCol.Name = "A" Then
    For Each dr As DataRow In e.DataRow.GetChildRows("子表")
        dr("B") = e.DataRow("B")
        dr("C") = e.DataRow("C")
    Next
End If


--  作者:newsun2k
--  发布时间:2014/10/27 11:56:00
--  
to:有点甜
代码改了一下:

datacolchanged代码

 

If e.DataCol.Name = "B" Then
    For Each dr As DataRow In e.DataRow.GetChildRows("子表")
        dr("B") = e.DataRow("B")
    Next
End If

没反应啊。
msgbox(e.DataRow.GetChildRows("子表").count) 始终显示0?


--  作者:newsun2k
--  发布时间:2014/10/27 11:59:00
--  
不好意思,知道了
GetChildRows("子表")
我没有写子表的名字,而是关联的名字

--  作者:有点甜
--  发布时间:2014/10/27 12:00:00
--  

 1、是不是你没有做父子表的关联?

 

 2、子表的表名是不是写错了?