以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  根据TG003前面6位数进行求最大值排号  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=172409)

--  作者:zhuxinhui
--  发布时间:2021/10/11 17:05:00
--  根据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) &"\'") \'取得该月的最大编号

--  作者:有点蓝
--  发布时间:2021/10/11 17:33:00
--  
max = e.DataTable.Compute("Max(TG002)","TG003 Like \'" & bh & "%\'") 
--  作者:zhuxinhui
--  发布时间:2021/10/11 18:59:00
--  
多谢