老师好,下面代码,一致没有问题,这几天只要增加行,输入日期,就提示“合同编号重复!”,我重新建一个项目,使用下面代码也都是正常的。为什么会这样那?
而且,下面代码也没有 “合同编号重复”的输出窗口提示。
Select Case e.DataCol.Name
Case "签约时间"
If e.DataCol.Name = "签约时间" Then
If e.DataRow.IsNull("签约时间") Then
e.DataRow("合同编号") = Nothing
Else
Dim d As Date = e.DataRow("签约时间")
Dim y As Integer = d.Year
Dim bh As String = Format(d, "yyyy") '生成编号的前4位,4位年
If e.DataRow("合同编号").StartsWith(bh) = False Then'如果编号的前4位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.SQLCompute("Max(合同编号)", "[_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(4, 6)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("合同编号") = bh & Format(idx, "000000")
Tables("销售合同").Current.Save()
End If
End If
End If
End Select