以文本方式查看主题

-  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=151586)

--  作者:13796361423
--  发布时间:2020/6/28 17:59:00
--  跨表引用数据

产品表和订单表通过产品编号联系起来,想要在订单表输入产品编号后,品名、型号、规格、单价四列内容从产品表自动继承输入,我在订单表的DataColChanged输入下面的事件代码, 为什么不通过啊, 我帮助看看代码呗

 

If

e.DataCol.Name = "产品编号"Then
If e.NewValue Is Nothing Then
e.
DataRow("品名") = Nothing
e.
DataRow("型号") = Nothing
e.
DataRow("规格") = Nothing
e.
DataRow("单价") = Nothing
Else
Dim dr AsDataRow
dr =
DataTables("产品").Find("[产品编号] = \'" & e.NewValue & "\'")
If
dr IsNot Nothing

e.
DataRow("品名") = dr("品名")
e.
DataRow("型号") = dr("型号")
e.
DataRow("规格") = dr("规格")
e.
DataRow("单价") = dr("单价")
End
If
End If
End
If


--  作者:linyunu
--  发布时间:2020/6/28 18:19:00
--  
DataTables("产品") 数据加载了吗?
--  作者:有点蓝
--  发布时间:2020/6/28 20:10:00
--  
已有的数据,选中订单表产品编号列,重置一下列

If e.DataCol.Name = "产品编号"Then
    If e.NewValue Is Nothing Then
        e.DataRow("品名") = Nothing
        e.DataRow("型号") = Nothing
        e.DataRow("规格") = Nothing
        e.DataRow("单价") = Nothing
    Else
        Dim dr AsDataRow
        dr = DataTables("产品").Find("[产品编号] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            e.DataRow("品名") = dr("品名")
            e.DataRow("型号") = dr("型号")
            e.DataRow("规格") = dr("规格")
            e.DataRow("单价") = dr("单价")
        End If
    End If
End If