473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Autonumber Format/Reset/Etc.

Hello,

I currently have a field named QuoteNumber in a table named Quotes.
The field is set as autonumber and is used to assign sequential numbers
as users enter information in the table through a form. This number is
mainly used later as reference when a customer calls our office with
questions. We use the quote number to retrieve their related
information through a query. This QuoteNumber field is NOT a primary
key. It is not important that the numbers be perfectly sequential, as
in when a record is deleted before saving, then the assigned autonumber
is lost as well.

Now my question/problem. I have formatted the autonumber field to view
as "05-000" where 05 represents the year, and the three digits after
the hyphen increase sequentially. However, I did not think ahead when
implementing this design, and now that it is 2006, I need to change the
numbers in front of the hyphen to 06 and reset the numbers after it to
start at 001. All previous quote numbers with the 05 prefix must
remain intact. I am thoroughly stuck and would appreciate any
constructive ideas, changes, workarounds, etc.

Jason

Jan 6 '06 #1
2 2731
ju*********@derrickcompany.com wrote:
Hello,

I currently have a field named QuoteNumber in a table named Quotes.
The field is set as autonumber and is used to assign sequential numbers
as users enter information in the table through a form. This number is
mainly used later as reference when a customer calls our office with
questions. We use the quote number to retrieve their related
information through a query. This QuoteNumber field is NOT a primary
key. It is not important that the numbers be perfectly sequential, as
in when a record is deleted before saving, then the assigned autonumber
is lost as well.

Now my question/problem. I have formatted the autonumber field to view
as "05-000" where 05 represents the year, and the three digits after
the hyphen increase sequentially. However, I did not think ahead when
implementing this design, and now that it is 2006, I need to change the
numbers in front of the hyphen to 06 and reset the numbers after it to
start at 001. All previous quote numbers with the 05 prefix must
remain intact. I am thoroughly stuck and would appreciate any
constructive ideas, changes, workarounds, etc.

Jason

Do you have a date field. Like QuoteDate? If so, you can format it so
the "05-" and "06-" are correct.

If not, create a new field called QuoteYear. I'll assume this is a
recent app since you just experienced this problem. Update all quote
records to "05"...to the last Quote for "05" and everything else is "06"

Now...regarding your numbering scheme. Open up the table in design
again and create a new field called NewQuoteID, longint. Now create a
query the updates NewQuoteID with the QuoteID number. Review to see
that is correct. If so, open the table in design and kill off the field
called QuoteID. Save the table. Now rename the field NewQuoteID to
QuoteID. You may want to renumber the existing records for 2006.

There's a couple of methods for assigning the quoteID. One uses DMax().
You check and find out what the max number is for that year and inc by
1. Or you can have a table that stores the years. It has 2 fields;
year, curnumber. When you create a new quote, it gets the current year.
It then reads the table and sees if 2006 exists (or whatever the
current year is). If not, it appends a record and sets the curnumber to
0.

When you SAVE the record...if you want to keep it sequential...you would
update the QuoteID in the BeforeUpdate event if it's a new
record...either by calling the Dmax() function or a function to read the
year table, get the current number, inc by 1, save it to the table, and
storing that value as the QuoteID for the current record.

You REALLY want to generate the quoteid when the record is saved. Why?
Because 2 people might create a Quote record around the same time and
you could end up with 2 quotes having the same number.

Other folks may have some better alternatives. Regardless, you have a
little bit of work ahead of you...not much...but enough to slow you down
for a couple of hours.
Jan 6 '06 #2
Thank you very much for that detailed and easy to understand
explanation! I'm pretty sure that will accomplish my goals.

salad wrote:
ju*********@derrickcompany.com wrote:
Hello,

I currently have a field named QuoteNumber in a table named Quotes.
The field is set as autonumber and is used to assign sequential numbers
as users enter information in the table through a form. This number is
mainly used later as reference when a customer calls our office with
questions. We use the quote number to retrieve their related
information through a query. This QuoteNumber field is NOT a primary
key. It is not important that the numbers be perfectly sequential, as
in when a record is deleted before saving, then the assigned autonumber
is lost as well.

Now my question/problem. I have formatted the autonumber field to view
as "05-000" where 05 represents the year, and the three digits after
the hyphen increase sequentially. However, I did not think ahead when
implementing this design, and now that it is 2006, I need to change the
numbers in front of the hyphen to 06 and reset the numbers after it to
start at 001. All previous quote numbers with the 05 prefix must
remain intact. I am thoroughly stuck and would appreciate any
constructive ideas, changes, workarounds, etc.

Jason

Do you have a date field. Like QuoteDate? If so, you can format it so
the "05-" and "06-" are correct.

If not, create a new field called QuoteYear. I'll assume this is a
recent app since you just experienced this problem. Update all quote
records to "05"...to the last Quote for "05" and everything else is "06"

Now...regarding your numbering scheme. Open up the table in design
again and create a new field called NewQuoteID, longint. Now create a
query the updates NewQuoteID with the QuoteID number. Review to see
that is correct. If so, open the table in design and kill off the field
called QuoteID. Save the table. Now rename the field NewQuoteID to
QuoteID. You may want to renumber the existing records for 2006.

There's a couple of methods for assigning the quoteID. One uses DMax().
You check and find out what the max number is for that year and inc by
1. Or you can have a table that stores the years. It has 2 fields;
year, curnumber. When you create a new quote, it gets the current year.
It then reads the table and sees if 2006 exists (or whatever the
current year is). If not, it appends a record and sets the curnumber to
0.

When you SAVE the record...if you want to keep it sequential...you would
update the QuoteID in the BeforeUpdate event if it's a new
record...either by calling the Dmax() function or a function to read the
year table, get the current number, inc by 1, save it to the table, and
storing that value as the QuoteID for the current record.

You REALLY want to generate the quoteid when the record is saved. Why?
Because 2 people might create a Quote record around the same time and
you could end up with 2 quotes having the same number.

Other folks may have some better alternatives. Regardless, you have a
little bit of work ahead of you...not much...but enough to slow you down
for a couple of hours.


Jan 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: deko | last post by:
Is there a way to reset the AutoNumber sequence? I have several tables that use the AutoNumber field as the Primary Key, and I'd like to somehow do an Import/Export that will make remove the...
3
by: Cillies | last post by:
Hello, I was wondering if anyone knew how to reset an auto number. I.E. in my database I have two tables with autonumbers as primary keys. So I was wondering if anyone knew an easy way of...
16
by: John Baker | last post by:
Hi: I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number...
4
by: Danny | last post by:
I have a db that has a table that is never deleted but just has records cleaned out "delete * from table" but each time it is populated, the autonumber is not reset to 0 and picks up where it...
4
by: yf | last post by:
A KB article "http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells that the maximum number of records that a table may hold if the PRIMARY key data type is set to AUTONUMBER is...
4
by: lamkelf | last post by:
Hi all, I have found solution for previous Access versions (i.e. compacting database) but it doesn't work with the 2003 version. Can someone point me to a website or give me some hints. ...
2
mkremkow
by: mkremkow | last post by:
Access 2003 on XP Someone here at work deleted a record (&$%^&*&!!!) and screwed up the Autonumber "Job ID" field . I need to reset the Autonumber field back to it's original numbers and still...
9
by: Gogo | last post by:
Database has record 59 showing, tabing to enter data returns autonumber to 134. What happened to cause this, how would I fix it?
5
by: troy_lee | last post by:
I have a table that has a PK field with the following format: Dyymm123. So that, a typical number might look like this D0806270. The first character is literal and never changes. The next four...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.