G
Guest
I have a database with a form that has the following coding:
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim mTable As String, mField As String, mYearPart As Long, mNextNumber
As Long
'number is returned as 6 characters: YY####
'where YY is the last 2 digits of the year
'#### is the next number for that year
'D is the DSCR Code
'format code to display this number should be "00D-0000"
mTable = "DSCR"
mField = "DSCRNumber"
mYearPart = Right(CStr(Year(Me.DSCRYear)), 2) * 10000
mNextNumber = Nz(DMax(mField, mTable, mField & ">=" & mYearPart), 0)
If mNextNumber = 0 Then
mNextNumber = mYearPart
End If
mNextNumber = mNextNumber + 1
Me.DSCRNumber = mNextNumber
Every so often - 5 out of a 100 - duplicate numbers are being assigned to
the form. However, when you check out the database there is only one number
being assigned. Can someone tell me what a user might be doing to get the
number and then another user can get the same number? Occasionally they are
on the same date; however, most are 3 or 4 days apart.
Thanks.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim mTable As String, mField As String, mYearPart As Long, mNextNumber
As Long
'number is returned as 6 characters: YY####
'where YY is the last 2 digits of the year
'#### is the next number for that year
'D is the DSCR Code
'format code to display this number should be "00D-0000"
mTable = "DSCR"
mField = "DSCRNumber"
mYearPart = Right(CStr(Year(Me.DSCRYear)), 2) * 10000
mNextNumber = Nz(DMax(mField, mTable, mField & ">=" & mYearPart), 0)
If mNextNumber = 0 Then
mNextNumber = mYearPart
End If
mNextNumber = mNextNumber + 1
Me.DSCRNumber = mNextNumber
Every so often - 5 out of a 100 - duplicate numbers are being assigned to
the form. However, when you check out the database there is only one number
being assigned. Can someone tell me what a user might be doing to get the
number and then another user can get the same number? Occasionally they are
on the same date; however, most are 3 or 4 days apart.
Thanks.