以文本方式查看主题

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

--  作者:紫色幽魂
--  发布时间:2019/1/21 16:05:00
--  [求助]手动触发列,修改日期
请问下,我在父表中增加代码,计算子表中的最早日期和最晚日期,重置列没有问题,但是在子表中增加代码后再新增行后会提示出错,提示没有引用到实例,是怎么回事儿
父表代码
Dim dt As DataTable =DataTables("无损_检测明细")
Dim F As String = "检验批编号 = \'" & e.DataRow("检验批编号") & "\'"
If e.DataCol.Name = "检验批" Then
    e.DataRow("检测日期_最早检测日期") = dt.SQLCompute("Min(首检_检测日期)",F)
    e.DataRow("检测日期_最后检测日期") = dt.SQLCompute("Max(首检_检测日期)",F)
End If


子表代码
If e.DataCol.name = "检验批" Then
    Dim pr As DataRow = e.DataRow.GetParentRow("无损_检验批") 
    If pr IsNot Nothing Then
        DataTables("无损_检验批").DataCols("检测日期_最早检测日期").RaiseDataColChanged(pr) 
        DataTables("无损_检验批").DataCols("检测日期_最后检测日期").RaiseDataColChanged(pr)
    End If
End If


--  作者:有点蓝
--  发布时间:2019/1/21 17:07:00
--  
父表代码
If e.DataCol.Name = "检验批编号" Then
Dim dt As DataTable =DataTables("无损_检测明细")
Dim F As String = "检验批编号 = \'" & e.DataRow("检验批编号") & "\'"
    e.DataRow("检测日期_最早检测日期") = dt.SQLCompute("Min(首检_检测日期)",F)
    e.DataRow("检测日期_最后检测日期") = dt.SQLCompute("Max(首检_检测日期)",F)
End If

子表代码
If e.DataCol.name = "检验批编号" orelse e.DataCol.Name = "首检_检测日期Then
Dim F As String = "检验批编号 = \'" & e.DataRow("检验批编号") & "\'"
    Dim pr As DataRow = DataTables("无损_检验批").find(F) 
    If pr IsNot Nothing Then
        DataTables("无损_检验批").DataCols("检验批编号").RaiseDataColChanged(pr) 
    End If
End If
[此贴子已经被作者于2019/1/21 17:07:32编辑过]