代码如下:
If e.DataCol.Name = "日期" Then
If e.DataRow.IsNull("日期") Then
e.DataRow("零售单编号") = Nothing
Else
Dim mn As WinForm.Form = Forms("零售录入窗口")
If mn.Opened = True Then
Dim mb As DataRow
Dim mv As String = mn.Controls("Label2").Text
Dim mc As String
mv = mv.Trim()
mb = DataTables("权限设置").Find("账号名 = '" & mv & "'")
If mb IsNot Nothing Then
mc = mb("账号编码")
Dim bh As String = mc & "-" & Format(e.NewValue,"yyyyMMdd") & "-" '取得编号的8位前缀
If e.DataRow("零售单编号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(零售单编号)","日期 = #" & e.NewValue & "# And [_Identify] <> " & e.DataRow("_Identify") ) '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(14,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("零售单编号") = bh & Format(idx,"000")
End If
End If
End If
End If
End If
我在零售录入窗口修改日期之后,有时候会弹出“未将对象应用设置到对象的实例”的错误,并且设置了默认日期,并增加行之后,零售单编号会出现重复。但是有的时候又一切正常,没有丝毫问题,求解是因为什么原因?