gold007eye
Registered User.
- Local time
- Yesterday, 19:30
- Joined
- May 11, 2005
- Messages
- 260
I have been racking my brain trying to get this to work with no success 
I have read through these 2 posts numerous times trying to apply the coding/methodolgy and can't seem to get it fine tuned.
http://access-programmers.co.uk/forums/showthread.php?t=31046&p=519211
http://www.access-programmers.co.uk/forums/showthread.php?t=112804&highlight=customid
Here is the structure I need to use for the number:
AR-CR-2007-00001
What I need is for the 00001 section to reset to 0 each year so the numbers will look like such:
AR-CR-2007-00001
AR-CR-2007-00002
AR-CR-2007-00003
AR-CR-2008-00001
AR-CR-2008-00002
AR-CR-2008-00003 etc....
I have the code working great to generate the different sections.
I have a table with 3 fields (seperating the number) and 1 field that is the combined number. The fields are:
FormatID (Text field),YearID (Text field),BaseID (Number field ) (These are populated using a form called "Test")
FormatID = AR-CR- (This is set as the default format/value)
YearID = 2007- (I have this obtained automatically using code in the default
value of the data tab)
BaseID = 00001 (Sequential by +1)
I have a button on the form called "Save" which I have placed this code in the "On-Click" event.
What I can't figure out is how to get the Base ID to restart with 00001 at the beginning of each year? What am I doing wrong?
I have also attached an image showing the increment change if I was to change the year to 2008 how it just incriments the last numbers instead of resetting to 00001.

I have read through these 2 posts numerous times trying to apply the coding/methodolgy and can't seem to get it fine tuned.
http://access-programmers.co.uk/forums/showthread.php?t=31046&p=519211
http://www.access-programmers.co.uk/forums/showthread.php?t=112804&highlight=customid
Here is the structure I need to use for the number:
AR-CR-2007-00001
What I need is for the 00001 section to reset to 0 each year so the numbers will look like such:
AR-CR-2007-00001
AR-CR-2007-00002
AR-CR-2007-00003
AR-CR-2008-00001
AR-CR-2008-00002
AR-CR-2008-00003 etc....
I have the code working great to generate the different sections.
I have a table with 3 fields (seperating the number) and 1 field that is the combined number. The fields are:
FormatID (Text field),YearID (Text field),BaseID (Number field ) (These are populated using a form called "Test")
FormatID = AR-CR- (This is set as the default format/value)
YearID = 2007- (I have this obtained automatically using code in the default
value of the data tab)
Code:
=Right(Date(),4) & "-"
BaseID = 00001 (Sequential by +1)
I have a button on the form called "Save" which I have placed this code in the "On-Click" event.
Code:
Private Sub Save_Click()
If IsNull(Me![BaseID]) Then
Me![BaseID] = Format(Nz(DMax("[BaseID]", "[tblTest]"), 0) + 1, "00000")
End If
Me![CustID] = [FormatID] & [DateID] & Format([BaseID], "00000")
End Sub
What I can't figure out is how to get the Base ID to restart with 00001 at the beginning of each year? What am I doing wrong?
I have also attached an image showing the increment change if I was to change the year to 2008 how it just incriments the last numbers instead of resetting to 00001.