Office中国论坛/Access中国论坛

标题: "日期型自动号"送给刚入门的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

在窗体视图中可用,数据表视图中不可用,请大虾们帮我改进一下,谢谢!

文件下载




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3