Autonumber field - restart each year
Hi, I have read each post I can find on this topic but I did not find any solution to my issue. I formed an access database (intended for volunteer work) that has an Autonumber field on the way to issue numbers to creatures taken in at our protection. My 'boss' (as well a volunteer) desires this easy Autonumber altered to a value that starts by the two figure year and after that has four digits, starting through 0001 that will increment in sequence and re-begin at 0001 through new calendar year. Thus, records will begin with 10-0001, 10-0002, and so on for this year as well as 11-0001, 11-0002 for after that year. Any help would be very much appreciated.
Re: Autonumber field - restart each year
There are two techniques to perform it, have an Autonumber Field as well as a Date field and merge them simple VBA to show the Number the manner which you would like. The only trouble by means of this technique is deleted or else cancelled records increase the Number, as a result you have gaps. The additional technique involves making use of a VBA recordset on the way to increment the value. I will recommend you to make use of the second technique.
Re: Autonumber field - restart each year
Thank you for your suggestion as you have mentioned I make use of the second technique, Got it to work and it told me to create another field which I did.On the other hand, I require to have this counter reset to one every year. Because the present code is working off the autonumber, I cannot reset it. Do I require to make one more numeric field plus have it increment every time the form is saved or else every time the triggering field through first data input on the has data enter similar to the code you mention at first? As I am not a VBA one I'm uncertain how to perform that. Thanks once more.
Re: Autonumber field - restart each year
It is not for the reason that you require a unique field it needs to be the primary key. The similar circumstances are present in invoice numbering, they need to be constantly numbered and re-begin by 1 every year. The most use solution for that is:the pk field, as usual, an autonumber that is unknown to the users. The unique number in this case, is generated automatically from the sysCounters table. Youcan use the following code for this purpose:
IDCount (autonumber) = PK
Typecount (number if you have a associated types table), you require only
countYear ( this makes it likely at the
beginning of a year to make a ticket for the most recent year, or else to make
already a number for the next year at the end of a year)
Valuecount: the last used number.