帮助里只看到按月编号和按日编号的,尝试了在按日编号基础上修正后进行按年自动编号出现错误,麻烦老师帮忙指正
If e.DataCol.Name = "录入时间" Then
If e.DataRow.IsNull("录入时间") Then
e.DataRow("年度编号") = Nothing
Else
Dim bh As String = Format(e.DataRow("录入时间"), "yyyy")
If e.DataRow("年度编号").StartsWith(bh) = False Then
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(年度编号)", "录入时间 = #" & e.DataRow("录入时间") & "# And [_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then
idx = CInt(max.Substring(9, 3)) + 1
Else
idx = 1
End If
e.DataRow("年度编号") = bh & "-" & Format(idx, "000")
End If
End If
End If