主表与明细表关联,下面代码如何改?
if e.datacol.name = "工序" then
dim idx as integer = tables("明细表").finrow(e.datarow)
if idx = 0 then
e.datarow("工序号") = 1
else
dim r as row = tables("明细表").rows(idx- 1)
if r("工序") = e.datarow("工序") then
e.datarow("工序号") = r("工序号")
else
e.datarow("工序号") = r("工序号") + 1
end if
end if
end if
数据是怎么样的?要实现什么功能?代码在哪个表的什么事件?执行有什么问题?
[此贴子已经被作者于2025/2/8 8:54:32编辑过]
If e.DataCol.name = "工序" Then
Dim dr As DataRow = e.DataTable.find("编号='" & e.DataRow("编号") & "' and 工序='" & e.DataRow("工序") & "' and _identiify<>" & e.DataRow("_identiify"))
If dr IsNot Nothing Then
e.DataRow("工序号") = dr("工序号")
Else
Dim max As Integer = e.DataTable.compute("max(工序号)", "编号='" & e.DataRow("编号") & "' and _identiify<>" & e.DataRow("_identiify"))
e.DataRow("工序号") = max + 1
End If
End If