以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]跨表引用及附加本表条件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144384)

--  作者:lgj716330
--  发布时间:2019/12/18 14:32:00
--  [求助]跨表引用及附加本表条件
Select Case e.DataCol.Name 
    Case "部门名称"
        If e.DataRow.IsNull("部门名称") Then
            e.DataRow("部门编码") = Nothing
        Else 
        Dim dr As DataRow
        dr = DataTables("责任中心档案").Find("[部门名称] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing And e.DataRow("科目编码") Like "6%" Then
            e.DataRow("部门编码") = dr("部门编号") 
        End If
        End If
End Select

上述标颜色部分要怎么写,上面的代码没起作用

--  作者:有点蓝
--  发布时间:2019/12/18 14:42:00
--  
请使用文字说明一下要实现什么逻辑?

--  作者:lgj716330
--  发布时间:2019/12/18 14:53:00
--  
当在A表部门名称列录入部门的时候,到“责任中心档案”寻找对应的部门编号,如果找到了并且A表的科目编码如果是6开头的,就把编号引用到A表的“部门编码”列里
--  作者:有点蓝
--  发布时间:2019/12/18 14:58:00
--  
Select Case e.DataCol.Name 
    Case "部门名称"
        If e.DataRow.IsNull("部门名称") orelse e.DataRow("科目编码") Like "6*" Then
            e.DataRow("部门编码") = Nothing
        Else 
        Dim dr As DataRow
        dr = DataTables("责任中心档案").Find("[部门名称] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then
            e.DataRow("部门编码") = dr("部门编号") 
        End If
        End If
End Select

--  作者:lgj716330
--  发布时间:2019/12/18 15:42:00
--  
应该用Not Like "6*" 但提示错误“应为语句结束”
--  作者:有点蓝
--  发布时间:2019/12/18 15:45:00
--  
If e.DataRow.IsNull("部门名称") orelse not e.DataRow("科目编码") Like "6*" Then

或者

Select Case e.DataCol.Name 
    Case "部门名称"
        If e.DataRow.IsNull("部门名称") Then
            e.DataRow("部门编码") = Nothing
        Else if e.DataRow("科目编码") Like "6*" then
        Dim dr As DataRow
        dr = DataTables("责任中心档案").Find("[部门名称] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then
            e.DataRow("部门编码") = dr("部门编号") 
        End If
        End If
End Select