-- 根据TG003前面6位数进行求最大值排号
If e.DataCol.Name = "TG003" Then \'TG003为日期,TG002为单号
If e.DataRow.IsNull("TG003") Then
e.DataRow("TG002") = Nothing
Else
Dim bh As String = e.DataRow("TG003").Substring(0,6) \'生成编号的前6位,4位年,2位月.
If e.DataRow("TG002").StartsWith(bh) = False \'如果编号的前6位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(TG002)","TG003 Like \'"& e.DataRow("TG003").Substring(0,6) &"\'") \'取得该月的最大编号
If max > "" Then \'如果存在最大编号
idx = CInt(max.Substring(6,5)) + 1 \'获得最大编号的后三位顺序号,并加1
Else
idx = 1 \'否则顺序号等于1
End If
e.DataRow("TG002") = bh & Format(idx,"00000")
End If
End If
End If
这句应该出问题了,只是求不出最大值

此主题相关图片如下:qq截图20211011170556.png

‘’‘max = e.DataTable.Compute("Max(TG002)","TG003 Like \'"& e.DataRow("TG003").Substring(0,6) &"\'") \'取得该月的最大编号