按面试室编号
假定有下图所示的一个表,编号根据面试室生成,前两位为面试室,抽签序号不按面试室*01,而是按面试室1为a,面试室2为b,面试室3为c面试室4为d面试室5为e,....,后2位为顺序号,最后在抽签序号里自动生成如面试室1为a01,...,面试室2为:b01,....
此主题相关图片如下:面试室.png

代码为:请修改一下
Select e.DataCol.Name
Case "面试室"
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 & "'") '取得该类别的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(2,2)) + 1 '获得最大编号的后2位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("抽签序号") = lb & Format(idx,"00")
End If
End If
End Select