以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]蓝版,帮忙看看跨表取数问题?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179250)

--  作者:bigeng
--  发布时间:2022/8/15 8:36:00
--  [求助]蓝版,帮忙看看跨表取数问题?
要求:假如合同编号不为空,按合同编号从合同表里取单价;假如合同编号为空,批次号不为空,则按照批次号从合同表里取单价。前面的能够正常取数,后面的合同编号为空,批次号不为空的时候,取不到数。
Select Case e.DataCol.Name
    Case "合同编号"
        If dr("合同编号") IsNot Nothing Then
            Dim pr As DataRow
            pr = DataTables("合同").Find("[合同编号] = \'" & e.NewValue & "\'")
            If pr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
                e.DataRow("单价") = pr("结算单价")
            End If
        ElseIf dr("批次号") IsNot Nothing Then
            Dim mr As DataRow
            mr = DataTables("合同").Find("[批次号] = \'" & e.NewValue & "\'")
            If mr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
                e.DataRow("单价") = mr("结算单价")
            End If
            
        End If
End Select

--  作者:kaiyu
--  发布时间:2022/8/15 8:43:00
--  
 批次号不为空下面那个e.newvalue改成e.datarow("批次号“)

--  作者:有点蓝
--  发布时间:2022/8/15 8:54:00
--  
Select Case e.DataCol.Name
    Case "合同编号","批次号"
        If dr.isnull("合同编号") =false Then
            Dim pr As DataRow
            pr = DataTables("合同").Find("[合同编号] = \'" & e.datarow("合同编号“) & "\'")
            If pr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
                e.DataRow("单价") = pr("结算单价")
            End If
        ElseIf dr.isnull("批次号")  =false Then
            Dim mr As DataRow
            mr = DataTables("合同").Find("[批次号] = \'" & e.datarow("批次号“) & "\'")

--  作者:bigeng
--  发布时间:2022/8/15 13:48:00
--  
可以了,谢谢!