|
Public Function ZDYBH1(StrTable As String, StrField As String, StrBH As String, Optional FDay As String = "YYYYMMDD", Optional ILen As Integer = 3, Optional bh As String) As String
'==================================================================
'功能: 自定义用户编号,带断号检测功能
'格式: "XXX"-"日期格式 "-"0000"
' StrTable 为任意表名称
' StrField 为任意字段名称
' StrBH 编码类型 , 可自义任意格式
' FDay 日期格式 默认日期格式为:YYMMDD",其他符合FORMAT格式的如 YYYYMM,YYYY,YYYYMMDD
' ILen 为数字格式化长度 , 默认长度为3 代表 000 格式
' B 为是否要检测断号 ,默认为FALSE 不检测
'用法: ZDYBH("产量表", "产量ID", "LDH")
' ZDYBH("产量表", "产量ID", Me.Combo1)
' ZDYBH("产量表", "产量ID", Me.Combo1, "YYYY")
' ZDYBH("产量表", "产量ID", Me.Combo1, , 4, True)
'作者: andymark
' QQ : 42503577 , ewang11@163.com
'日期: 2008-4-2
'===============================================================
Dim Str As String
Dim Num As Integer
Dim TNum As Integer
Dim StrWhere As String
Dim StrOrderWhere As String
Dim StrOrderWhereDesc As String
Str = Format(Now(), "" & FDay & "")
OpenRS1 "select " & StrField & " from " & StrTable & " where " & StrField & " like '" & Str & "%' Order by " & StrField & " DESC", Rs
OpenRS1 "select " & StrField & " from " & StrTable & " where " & StrField & " like '" & Str & "%' Order by " & StrField & "", Rs1
If Rs.EOF Then
Num = 0
Else
Num = Mid(Rs.Fields("" & StrField & ""), 10, ILen)
End If
ZDYBH1 = Format(Now(), "" & FDay & "") & "" & bh & "" & Format(Num + 1, String(ILen, "0")) & StrBH
Openrs "INSERT INTO " & StrTable & "(" & StrField & "" & _
") values ( '" & ZDYBH1 & "')", Rs2
Set Rs1 = Nothing
End Function
|
|