以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  表B中datacolchanged事件程序统计数据写到表A中  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=180031)

--  作者:小螺号
--  发布时间:2022/9/23 22:40:00
--  表B中datacolchanged事件程序统计数据写到表A中
有A表单位信息表,B表人员信息表,并以所在单位建立关联,现想在B表中的“编制类型”列发生变化时自动统计在A表中的“行政编制”、“事业编制”、“工勤编制”三列中,在表B中的datacolchanged事件中编辑了如下程序后总是报错,请高手指点:

If e.DataCol.Name = "编制类型" Then
    Dim Values As New List(Of String) From {"行政编制", "事业编制", "工勤编制"}
    For Each Value As String In Values
        If Value = "行政编制" Then
           DataTables("表A").dataRows("实有_行政编制") = DataTables("表B").Compute("count(编制类型)", "所在单位 = \'" & e.DataRow("所在单位") & "\' and 编制类型=\'行政编制\'") 
        ElseIf Value = "事业编制" Then
           DataTables("表A").dataRows("实有_事业编制") = DataTables("表B").Compute("count(编制类型)", "所在单位 = \'" & e.DataRow("所在单位") & "\' and 编制类型=\'事业编制\'") 
        ElseIf Value = "工勤编制" Then
           DataTables("表A").datarows("实有_工勤编制") = DataTables("表B").Compute("count(编制类型)", "所在单位 = \'" & e.DataRow("所在单位") & "\' and 编制类型=\'工勤编制\'") 
            Exit For
        End If
    Next
End If

--  作者:有点蓝
--  发布时间:2022/9/24 9:20:00
--  
If e.DataCol.Name = "编制类型" Then
dim dr as datarow = DataTables("表A").Find("count(编制类型)", "所在单位 = \'" & e.DataRow("所在单位") & "\'") 
if dr isnot nothing then
if e.oldvalue > "" then
dr("实有_" & e.oldvalue) = e.DataTable.Compute("count(编制类型)", "所在单位 = \'" & e.DataRow("所在单位") & "\' and 编制类型=\'" & e.oldvalue & "\'") 
end if
if e.newvalue > "" then
dr("实有_" & e.newvalue ) = e.DataTable.Compute("count(编制类型)", "所在单位 = \'" & e.DataRow("所在单位") & "\' and 编制类型=\'" & e.newvalue  & "\'") 
end if
end if
End If

--  作者:小螺号
--  发布时间:2022/9/24 22:55:00
--  
感谢有点蓝,我好好消化一下。