Reseting autonumber to start again from 1 (2 Viewers)

marystewart78

Registered User.
Local time
Today, 17:51
Joined
Aug 16, 2005
Messages
30
Hi Folks,

I'm looking to create an autonumber field which will work normally (ie increase 1 number at a time) but at the beginning of a new year I'd like it to automatically return to the number 1 again and start increasing 1 at a time again.

Any help on this would be appreciated!

Many Thanks,

Mary
 

richary

Registered User.
Local time
Today, 17:51
Joined
May 26, 2004
Messages
167
Autonumber is not suitable for this. Use an ordinary Integer field and use the DMax function with the current year in the criteria string to assign a number.
 

jsanders

If I Only had a Brain
Local time
Today, 12:51
Joined
Jun 2, 2005
Messages
1,940

wkalo

Registered User.
Local time
Today, 19:51
Joined
Sep 14, 2005
Messages
42
you Can Copy And Paste The Table And Set copy Structure Only. So If you Try To Input A New Field It Will Start At 1

Try ...... I Did And It Works
Good Luck !!!
 
R

Rich

Guest
Mary doesn't want a new field, she wants to keep the existing one
 

halem2

Registered User.
Local time
Today, 12:51
Joined
Nov 8, 2006
Messages
180
I followed WKALO's suggestion and it does work like a charm. Thanks!:D
 

wkalo

Registered User.
Local time
Today, 19:51
Joined
Sep 14, 2005
Messages
42
Glad To Help Good Luck With Your Project
 

Mile-O

Back once again...
Local time
Today, 17:51
Joined
Dec 10, 2002
Messages
11,316
You copied and pasted the table? So now you have, what, two identical tables? Madness!
 

Mile-O

Back once again...
Local time
Today, 17:51
Joined
Dec 10, 2002
Messages
11,316
Yes, so two identical tables...in structure. The content is irrelevant. Still madness!
 

durexlw

Registered User.
Local time
Today, 18:51
Joined
Feb 27, 2008
Messages
23
What you did is a good example of making yourself work for your PC...

Just write some code that operates on this idea and save yourself a headache:

Code:
|-----------|
| Testtable |
|-----------|
| ID        |
| Counter   |
| Year      |
|-----------|

Counter is a number
Year is a date
ID is a custom key that operates on this idea:

if Newinsert.Year <> Lastinsert.Year then
    [Counter] = 1
    [ID] = Newinsert.Year & [Counter]
Else
    [Counter] = Lastinsert.Counter + 1
    [ID] = Newinsert.Year & [Counter]
End If

(With 'Lastinsert.' I mean, lookup the value of the last record in your table.
'Newinsert.' are the values the user is trying to insert.)

Obviously you can optimize this code, even write it in a single line as a default value rule, but you'll probably get the idea... make the PC work for you... not the other way around.
 

Users who are viewing this thread

Top Bottom