Start by revising your storage... store the sequential number, as a numeric
integer or long integer, separately from the text portion of your invoice
number... format and concatenate them when you need to display or use them.
That will simplify incrementing the sequential number...
In the future, it would be helpful if you would tell us _what_ you are
trying to do, instead of giving code that "almost works" for us to either
determine, or guess, what you are trying to do from the "how you thought it
would work and it almost did".
Trying to have "coded" identification, as your invoice number, was
convenient in manual systems, but rarely necessary in automated systems. A
number which uniquely identifies the entity works nicely, and information
such as date, category, etc., are easily retrievable. If it is necessary to
satisfy the managment, or users, with "coded" identification, it is much
easier to form the coded identification when needed to be displayed to the
humans to whome it may be meaningful, rather than storing it in humanly
convenient form in a medium (rotating memory on a computer) that a human
can't even see.
Larry Linson
Microsoft Access MVP
"luanhoxung" <lu********@yahoo.comwrote in message
news:4f******************************@localhost.ta lkaboutdatabases.com...
hi Rick & all !
Maybe i need your help revising my code.
i create my invoice number as code below.
It nearly work as my mine.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim DB As Database
Dim RS As Recordset
Dim Str As String
Dim i As Integer
Set DB = CurrentDb
Set RS = DB.OpenRecordset("TCHITIETHANGXUAT", dbOpenSnapshot)
Str = "-" & Format(Month(Date), "00") & Right(Year(Date), 2) & "/VF"
Me.INV.Format = Str
If RS.RecordCount 0 Then
i = Left(DMax("inv", "tchitiethangxuat"), 4) + 1
Me.INV = Format(i.Text, "0000") & Str ------i want cover i to text but not
succeed, i want to store i with 4 characters---
Else
Me.INV = "0001" & Str
End If
End Sub
how can i do this ??
Any ideas will be appreciated.
thansk in advance
Luan from VietNam