|
自增记录
=================================
建一个名叫“记录”的表,有字段“日期”,“序号”
function DaimaShengcheng()
Dim myrecordset, myLookup As Variant
myLookup = Dlookup("日期", "记录")
If IsNull(myLookup) Then
Set myrecordset = CurrentDb.OpenRecordset("记录")
With myrecordset
.AddNew
!日期 = Date
!序号= 1
.Update
End With
DaiMaShengCheng = 1
End If
If myLookup = Date Then
Set myrecordset = CurrentDb.OpenRecordset("记录")
DaiMaShengCheng = myrecordset!Dòo? + 1
With myrecordset
.Edit
!序号= DaiMaShengCheng
.Update
End With
ElseIf myLookup < Date Then
Set myrecordset = CurrentDb.OpenRecordset("记录")
With myrecordset
.Edit
!日期 = Date
!序号 = 1
.Update
End With
DaiMaShengCheng = 1
End If
end function
'实现
RESULT=format(date(),"yyyymmdd") & "-" & format(daimashengcheng,"000")
|
|