标题: "日期型自动号"送给刚入门的MMDD [打印本页] 作者: yrg 时间: 2003-3-6 03:24 标题: "日期型自动号"送给刚入门的MMDD Function HmyID2(Zd As String, Hb As String, J As String) As String
Dim MaxNo As String '定义最大编号
On Error GoTo Err_11
MaxNo = Nz(Mid(DMax(Zd, Hb), 2, 11)) '获取最后一条记录的单号(最大单号)
If Val(Left(MaxNo, 8)) = Val(Format(Date, "yyyymmdd")) Then
HmyID2 = J & ((Val(MaxNo) + 1))
Else
HmyID2 = J & Format(Date, "yyyymmdd") & "001"
End If
Exit_11:
Exit Function
Err_11:
MsgBox Err.Description
Resume Exit_11
End Function