S
Sondra
I have a form with the following code:
**********************
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) * 1000
mNextNumber = Nz(DMax(mField, mTable, mField & ">=" & mYearPart), 0)
If mNextNumber = 0 Then
mNextNumber = mYearPart
End If
mNextNumber = mNextNumber + 1
Me.DSCRNumber = mNextNumber
End Sub
***************
The procedure is working correctly with one exception. I would like the
user to see the following in the field 05D-0001, etc., but what they see is
050001.
Can someone advise how to force the field to look as "00"D-"0000 versus 000000
Thanks in advance.
**********************
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) * 1000
mNextNumber = Nz(DMax(mField, mTable, mField & ">=" & mYearPart), 0)
If mNextNumber = 0 Then
mNextNumber = mYearPart
End If
mNextNumber = mNextNumber + 1
Me.DSCRNumber = mNextNumber
End Sub
***************
The procedure is working correctly with one exception. I would like the
user to see the following in the field 05D-0001, etc., but what they see is
050001.
Can someone advise how to force the field to look as "00"D-"0000 versus 000000
Thanks in advance.