如下图所示,希望订单明细中数量发生变化时,对应的申请单的数量也要变化。我在窗体关闭按钮中放了代码,但不执行此主题相关图片如下:1.png
关闭按钮的代码如下:
If Tables("pomain.posub").Current IsNot Nothing Then
Dim rrr As Row = Tables("pomain").Current
For Each dr1 As DataRow In DataTables("posub").Select("[订单号] = '" & rrr("订单号") & "'" )
Dim Val As Integer
Val = DataTables("posub").SQLCompute("Sum(数量)","申请单子表标识 = '"& dr1("申请单子表标识") &"'")
Dim dr As DataRow = DataTables("prsub").find("pr子表标识 = '" & dr1("申请单子表标识") & "' ")
If dr IsNot Nothing Then
dr("订单数量") = Val
End If
Next
Else
Tables("pomain").Current.Delete
End If
DataTables("posub").save
Tables("pomain").AllowEdit = False
Tables("pomain.posub").AllowEdit = False
Tables("posub").AllowEdit = False
e.Form.close
我又单独放了一个按钮,代码如下,就可以更新数据,不知道为什么关闭窗体的按钮代码不执行。
Dim rrr As Row = Tables("pomain").Current
For Each dr1 As DataRow In DataTables("posub").Select("[订单号] = '" & rrr("订单号") & "'" )
Dim Val As Integer
Val = DataTables("posub").SQLCompute("Sum(数量)","申请单子表标识 = '"& dr1("申请单子表标识") &"'")
Dim dr As DataRow = DataTables("prsub").find("pr子表标识 = '" & dr1("申请单子表标识") & "' ")
If dr IsNot Nothing Then
dr("订单数量") = Val
End If
Next