以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  DataColChanged  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=177799)

--  作者:飘过的巨蟹座
--  发布时间:2022/6/5 5:48:00
--  DataColChanged
我再全局表DataColChanged里面添加了函数Functions.Execute("全局表数据DataColChanged",e)
然后函数里面的代码是
Dim e = Args(0)
Select Case e.DataTable.Name 
    Case "ddyg"
        If e.DataCol.Name = "zbm" Then \'如果内容发生变动的是品名列
    If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空
        e.DataRow("mdbh") = Nothing \'那么清空此行单价列的内容
    Else
        Dim dr As DataRow
        \'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
        dr = DataTables("ddbm").Find("[name] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
            e.DataRow("mdbh") = dr("jj")
        End If
    End If
End If

If e.DataCol.Name = "mdbh" Then \'如果内容发生变动的是品名列
    If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空
        e.DataRow("id") = Nothing \'那么清空此行单价列的内容
    Else
        Dim dr As DataRow
        \'否则在产品表查找同名的产品行,将找到的行赋值给变量dr
        dr = DataTables("dpdzm").Find("[KHDM] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
            e.DataRow("ID") = dr("id")
        End If
    End If
End If


If e.DataCol.Name = "ygzt" Then \'如果内容发生变动的是品名列
    If e.DataRow("ygzt") <> "离职" Then \'如果新值是空白,也就是品名列的内容为空
        e.DataRow("lzrq") = Nothing \'那么清空此行单价列的内容
    ElseIf e.DataRow("ygzt") = "离职" Then
        e.DataRow("lzrq") = Date.Today
    End If
End If
    Case "表B"
        \'针对表B的代码
    Case "表C"
        \'针对表C的代码
End Select

但是为什么没有效果呢?我试了重置列,也是没有效果

--  作者:狐狸爸爸
--  发布时间:2022/6/5 6:47:00
--  
全局表事件默认就是不执行的,需要开启,参考: