1、自动编号
Private Sub NewId()
Dim ID, date2 As String
If IsNull([客户ID]) Or IsNull([日期]) Then
Me.单据编号 = Null
Else
date2 = "CG" & Format([日期], "YYYYMM")
ID = DMax("[单据编号]", "[出入库表]", "[单据编号] Like '" & date2 & "???'")
If IsNull(ID) Then
Me.单据编号 = date2 & "001"
Else
Me.单据编号 = date2 & Format(CStr(CInt(Right(ID, 3)) + 1), "000")
End If
End If
End Sub