以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  自动赋值  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=121414)

--  作者:qinlao666
--  发布时间:2018/7/5 16:36:00
--  自动赋值
表A,有A,B两列, 表B,有c,D两列
当填写表B的C列时,如果D列的内容等于表A的B列的内容,就将这行C的值自动赋给表A的A列

请问老师如何写代码

--  作者:有点蓝
--  发布时间:2018/7/5 17:15:00
--  
表B,datacolchanged事件

If e.DataCol.Name = "C列" Then 
    Dim dr As DataRow
    dr = DataTables("表A").Find("[关联列,如编号] = \'" & e.DataRow("编号) & "\'")
    If dr IsNot Nothing AndAlso dr("B列") = e.DataRow("D列") Then 
        dr("A列") = e.DataRoW("C列")
    End If
End If

--  作者:qinlao666
--  发布时间:2018/7/6 14:39:00
--  
删掉A列的值,C列也自动删除,请问老师代码如何改
--  作者:有点甜
--  发布时间:2018/7/6 14:44:00
--  

表A,datacolchanged事件


If e.DataCol.Name = "A列" Then 
    Dim dr As DataRow
    dr = DataTables("表B").Find("[关联列,如编号] = \'" & e.DataRow("编号) & "\'")
    If dr IsNot Nothing AndAlso dr("D列") = e.DataRow("B列") Then 
        dr("C列") = e.DataRoW("A列")
    End If
End If
[此贴子已经被作者于2018/7/6 14:43:52编辑过]