为啥不能生成自动编号呢?代码如下:Select e.DataCol.Name
Case "领料日期","简码"
If e.DataRow.IsNull("领料日期") OrElse e.DataRow.IsNull("简码") Then
e.DataRow("领料单号") = Nothing
Else
Dim d As Date = e.DataRow("领料日期")
Dim bh As String = e.DataRow("简码") & "-" & Format(d,"yyyyMMdd") & "-" '生成编号的前缀
If e.DataRow("领料单号").StartsWith(bh) = False '如果领料单号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "简码 = '"& e.DataRow("简码") & "' And 领料日期 >= #" & d & "# And 领料日期 < #" & d.AddDays(1) & "# And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(领料单号)",flt) '取得该月的相同简码的最大领料单号
If max > "" Then '如果存在最大领料单号
idx = CInt(max.Substring(bh.length, 4)) + 1 '获得最大领料单号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("领料单号") = bh & Format(idx,"0000")
End If
End If
End Select