Select e.DataCol.Name
Case "年月"
'If e.DataRow.name="年月" Then
If e.DataRow.IsNull("年月") Then
e.DataRow("数据编号") = Nothing
Else
Dim lb As String = e.DataRow("年月")
If e.DataRow("数据编号").StartsWith(lb) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(数据编号)","年月 = '" & lb & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该类别的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(2,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("数据编号") = lb & Format(idx,"000")
End If
End If
我在datacolchanged事件中加入上述的程序段,想自动生成数据数据编号,但没有成功。所有的数据行没有编号的时候是成功的,生成了“201611001”,但后面只有生相同的编号“201611162”,没有按原来“201611002”。。。。为什么会这样?