蓝老师您好!我用下面的代码自动编号,序号不自动增加,请指导'序号自动编号
Select e.DataCol.Name
Case "分类", "分组"
If e.DataRow.IsNull("分类") OrElse e.DataRow.IsNull("分组") Then
e.DataRow("序号") = Nothing
Else
Dim bh As String = e.DataRow("分类") & e.DataRow("分组") '生成序号的前缀
If e.DataRow("序号").StartsWith(bh) = False Then'如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "序号 = '" & e.DataRow("分类") & "' And '" & e.DataRow("分组") & "' And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(序号)", flt) '取得最大单据序号
If max > "" Then '如果存在最大编号
' idx = CInt(max.Substring(6, 2)) + 1 '获得最大编号的后2位顺序号,并加1
idx = CInt(max.Substring(max.length - 2)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("序号") = bh & Format(idx, "00")
End If
End If
End Select