应该:
If dr1 IsNot Nothing Then
e.DataRow("未入库数量") = dr1("数量") - e.DataRow("累计入库数量")
End If
另外判断空值的方法不对,正确的方法:
http://www.foxtable.com/help/topics/1470.htm
综合起来,应该:
Select Case e.DataCol.name
Case "到货时间"
Dim dr As DataRow = DataTables("订单明细").Find("订单编号 = '" & e.DataRow("订单编号") & "' AND 存货编码 = '" & e.DataRow("存货编码") & "' AND 规格型号 = '" & e.DataRow("规格型号") & "'")
If dr IsNot Nothing Then
dr("到货时间") = e.DataRow("到货时间")
End If
Case "入库日期"
If e.DataRow.Isnull("入库日期")= False Then
If e.DataRow.Isnull("存货编码") = False Then
e.DataRow("累计入库数量") = DataTables("入库明细").Compute("Sum(数量)","[订单编号] = '" & e.DataRow("订单编号") & "' AND [存货编码]='" & e.DataRow("存货编码") & "' AND [规格型号]='" & e.DataRow("规格型号") & "'")
Dim dr1 As DataRow = DataTables("订单明细").Find("订单编号 = '" & e.DataRow("订单编号") & "' AND 存货编码 = '" & e.DataRow("存货编码") & "' AND 规格型号 = '" & e.DataRow("规格型号") & "'")
If dr1 IsNot Nothing Then
e.DataRow("未入库数量") = dr1("数量") - e.DataRow("累计入库数量")
End If
End If
Else
MessageBox.Show("你还有未输入的到货单,请核对后再刷新")
e.cancel=True
End If
End Select
[此贴子已经被作者于2016/3/18 12:34:02编辑过]