王芬芳 发表于:2015-04-29 09:05:16
我想根据不同的单据类型(C/D)+不同的录入人员+不同的供应商+同一天内+是否为最后一张单,这些条件来生成单号
Public Function GetNewNum(byval billtype as string,byval username as string,byval supplier as string,dt as date) as string
'功能:返回新单号
'参数:billtype -- 单据类型
' username -- 用户名
' supplier -- 供应商
' dt -- 日期
Dim MaxNum as string
Dim wh as string
Dim str as string
wh="单据类型='{0}' and 用户名='{1}' and 供应商='{2}' and 录入日期=#{3}#"
wh=ReplaceValues(wh,billtype,username,supplier,dt)
str="{0}_{1}_{2}_{3}_"
wh=ReplaceValues(str,billtype,username,supplier,dt)
MaxNum=Nz(Dmax("单号","阁下的表名",wh ),str & "00")
GetNewNum=str & Format(val(right(MaxNum,2))+1,"00")
End Function
Public Function ReplaceValues(ByVal str As String, ParamArray pArr() As Variant) As String
'功能:模仿.Net中的String.Format方法
Dim str1 As String
Dim num As String
Dim i As Integer
str1 = str
For i = 0 To UBound(pArr)
num = "{" & i & "}"
str1 = Replace(str1, num, pArr(i))
Next
ReplaceValues = str1
End Function
快速开发平台--根据两个字段自动生成编号示例\双字段编号[Access软件网]
http://www.accessoft.com/article-show.asp?id=9903
总记录:2篇 页次:1/1 9 1 :