473,728 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generating auto number with a specific prefix

hello,

this seems to be a hard question so far and noone has been able to help
with this. is it possible to have access start an autonumber with a
prefix according to the year when the data is entered. for example, if
i entered something in 2004, i would like the number to bigin with
2004003, 2004004, 2004005... and same for 2005001, 2005002...?
much and great appreciation for suggestions.

thank you,

the hotshot

Nov 13 '05 #1
4 10648
If you search this group on "autonumber " you'll find a lot of advice.

Autonumber is a field type that is really a long integer, with some hidden
code
to increment the value for every added record. I do NOT recommend
any of these pseudoID forms that use combinations of initials/date/other,
as they ALL will eventually fail and most are vulnerable to user input
mistakes.
Trying to "imbed" data within an ID is almost always a bad idea.
Most good data designs have a primary key for each table,
generally an autonumber field. Most applications do not display that ID, but
use it internally for relational integrity. If you want to show the records
entered in any particular year,
you should be using a query to filter records based on a real date range.

That said, one of the more common solutions for what you ask, is to
concatenate
2 fields in the format that you require. Keep the standard autonumber
field, then add a [DateEntered] field
to your table and data entry form. Make this a date/time field type and set
the default value to Date().
This will automatically enter the system date anytime a new record is added.
On your forms/reports
that need the pseudoID displayed, create an unbound textbox and set its
control source to something like:
=DatePart("yyyy ",[DateEntered])&[AutonumberField Name]

-Ed


"the hotshot" <ho*****@inbox. lv> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
hello,

this seems to be a hard question so far and noone has been able to help
with this. is it possible to have access start an autonumber with a
prefix according to the year when the data is entered. for example, if
i entered something in 2004, i would like the number to bigin with
2004003, 2004004, 2004005... and same for 2005001, 2005002...?
much and great appreciation for suggestions.

thank you,

the hotshot

Nov 13 '05 #2
thank you for the great advice Ed. i cant pass the stage of creating an
unbound textbox. maybe it would be possible to also help with this
step? i tried looking on the net on how to do it, but there are no
clear explanations, only definitions of it.

thanks again,

the hotshot
Ed Robichaud wrote:
If you search this group on "autonumber " you'll find a lot of advice.

Autonumber is a field type that is really a long integer, with some hidden code
to increment the value for every added record. I do NOT recommend
any of these pseudoID forms that use combinations of initials/date/other, as they ALL will eventually fail and most are vulnerable to user input mistakes.
Trying to "imbed" data within an ID is almost always a bad idea.
Most good data designs have a primary key for each table,
generally an autonumber field. Most applications do not display that ID, but use it internally for relational integrity. If you want to show the records entered in any particular year,
you should be using a query to filter records based on a real date range.
That said, one of the more common solutions for what you ask, is to
concatenate
2 fields in the format that you require. Keep the standard autonumber field, then add a [DateEntered] field
to your table and data entry form. Make this a date/time field type and set the default value to Date().
This will automatically enter the system date anytime a new record is added. On your forms/reports
that need the pseudoID displayed, create an unbound textbox and set its control source to something like:
=DatePart("yyyy ",[DateEntered])&[AutonumberField Name]

-Ed


"the hotshot" <ho*****@inbox. lv> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
hello,

this seems to be a hard question so far and noone has been able to help with this. is it possible to have access start an autonumber with a
prefix according to the year when the data is entered. for example, if i entered something in 2004, i would like the number to bigin with
2004003, 2004004, 2004005... and same for 2005001, 2005002...?
much and great appreciation for suggestions.

thank you,

the hotshot


Nov 13 '05 #3
Sure. Unbound text boxes are just a text box control on a form/report that
are not "bound" to a specific field in a data table/query. To create one,
do not drag and drop from the field list. Use the toolbox wizard to place a
text box on your form. In the control source property, put the expression:
=DatePart("yyyy ",[DateEntered])&"-"&[AutonumberField Name]

(assuming that you have bound controls on your form, named
"DateEntere d" -bound to a date/time field in your table/query that has a
default value of Date() - and "AutonumberFiel dName" bound to the primary
key of your table/query - more likely called something like CustomerID)

This will then display (but not store in a table) the combined values -i.e.
"2004-001", "20043-002", etc. You would need to copy that control to any
form/report that needs to display the same info.
-Ed

"the hotshot" <ho*****@inbox. lv> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
thank you for the great advice Ed. i cant pass the stage of creating an
unbound textbox. maybe it would be possible to also help with this
step? i tried looking on the net on how to do it, but there are no
clear explanations, only definitions of it.

thanks again,

the hotshot
Ed Robichaud wrote:
If you search this group on "autonumber " you'll find a lot of advice.

Autonumber is a field type that is really a long integer, with some

hidden
code
to increment the value for every added record. I do NOT recommend
any of these pseudoID forms that use combinations of

initials/date/other,
as they ALL will eventually fail and most are vulnerable to user

input
mistakes.
Trying to "imbed" data within an ID is almost always a bad idea.
Most good data designs have a primary key for each table,
generally an autonumber field. Most applications do not display that

ID, but
use it internally for relational integrity. If you want to show the

records
entered in any particular year,
you should be using a query to filter records based on a real date

range.

That said, one of the more common solutions for what you ask, is to
concatenate
2 fields in the format that you require. Keep the standard

autonumber
field, then add a [DateEntered] field
to your table and data entry form. Make this a date/time field type

and set
the default value to Date().
This will automatically enter the system date anytime a new record is

added.
On your forms/reports
that need the pseudoID displayed, create an unbound textbox and set

its
control source to something like:
=DatePart("yyyy ",[DateEntered])&[AutonumberField Name]

-Ed


"the hotshot" <ho*****@inbox. lv> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
> hello,
>
> this seems to be a hard question so far and noone has been able to help > with this. is it possible to have access start an autonumber with a
> prefix according to the year when the data is entered. for example, if > i entered something in 2004, i would like the number to bigin with
> 2004003, 2004004, 2004005... and same for 2005001, 2005002...?
> much and great appreciation for suggestions.
>
> thank you,
>
> the hotshot
>

Nov 13 '05 #4
Thank you so much Ed. I received more help then anticipated. I still
need to fogure out how to create the unbound text box - all of this is
new to me. Will try to do in the next few days.

Thanks!

Ed Robichaud wrote:
Sure. Unbound text boxes are just a text box control on a form/report that are not "bound" to a specific field in a data table/query. To create one, do not drag and drop from the field list. Use the toolbox wizard to place a text box on your form. In the control source property, put the expression: =DatePart("yyyy ",[DateEntered])&"-"&[AutonumberField Name]

(assuming that you have bound controls on your form, named
"DateEntere d" -bound to a date/time field in your table/query that has a default value of Date() - and "AutonumberFiel dName" bound to the primary key of your table/query - more likely called something like CustomerID)
This will then display (but not store in a table) the combined values -i.e. "2004-001", "20043-002", etc. You would need to copy that control to any form/report that needs to display the same info.
-Ed

"the hotshot" <ho*****@inbox. lv> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
thank you for the great advice Ed. i cant pass the stage of creating an unbound textbox. maybe it would be possible to also help with this
step? i tried looking on the net on how to do it, but there are no
clear explanations, only definitions of it.

thanks again,

the hotshot
Ed Robichaud wrote:
If you search this group on "autonumber " you'll find a lot of advice.
Autonumber is a field type that is really a long integer, with some
hidden
code
to increment the value for every added record. I do NOT recommend
any of these pseudoID forms that use combinations of

initials/date/other,
as they ALL will eventually fail and most are vulnerable to user

input
mistakes.
Trying to "imbed" data within an ID is almost always a bad idea.
Most good data designs have a primary key for each table,
generally an autonumber field. Most applications do not display
that ID, but
use it internally for relational integrity. If you want to show
the records
entered in any particular year,
you should be using a query to filter records based on a real date

range.

That said, one of the more common solutions for what you ask, is
to concatenate
2 fields in the format that you require. Keep the standard

autonumber
field, then add a [DateEntered] field
to your table and data entry form. Make this a date/time field type and set
the default value to Date().
This will automatically enter the system date anytime a new record
is added.
On your forms/reports
that need the pseudoID displayed, create an unbound textbox and
set its
control source to something like:
=DatePart("yyyy ",[DateEntered])&[AutonumberField Name]

-Ed


"the hotshot" <ho*****@inbox. lv> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
> hello,
>
> this seems to be a hard question so far and noone has been able
to help
> with this. is it possible to have access start an autonumber
with a > prefix according to the year when the data is entered. for example, if
> i entered something in 2004, i would like the number to bigin

with > 2004003, 2004004, 2004005... and same for 2005001, 2005002...?
> much and great appreciation for suggestions.
>
> thank you,
>
> the hotshot
>


Nov 13 '05 #5

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

Similar topics

0
1496
by: oo00oo | last post by:
Hi people, I am trying to make my own auto_increment for some tables as the ID's have a string prefix in front of them. For example: - customer table has the prefix CUS, - employee table has the prefix EMP, - item table has different prefixes like WB, WC, TFB, etc... The difficulty i am having is finding the last inserted row for that table. When I use the following SQL statement I don't get what i would
7
1887
by: Eddie | last post by:
I searched with my problem but with no results :( My question is: how can I generate string, having only simple pattern, like, midend For example tyis pattern should reproduce strings like: 1. 0min4end 2. 0min5end 3. 0min6end 4. 0min7end
6
3813
by: Sebastien | last post by:
Hi, I am building a products database, linking sales and production. Each part has a unique sales Stock Code and Production Number. The sales stock code is a combination of letters and numbers taken from the part name (BrandA 300 4 Bladed : B3004B). The production number is a 4 or 5 digits number with first figure(s) indicating category (BrandA 300 4 Bladed: BrandA is category 1000. This Product would be 1003 if it was the third...
11
2550
by: Gary | last post by:
I'm using Access 2002. I have a field called Job No. It is a text (data type). The reason being that there is an "I" in front of each number i.e. I1234 I1235 etc The problem is that when the user enters a new record, he/she has to know what the last recorded job no. is present in the database, in order to then assign the next sequential job no. So its a manual process. I don't want to seperate the "I" component from the Job No....
4
11398
by: petermichaux | last post by:
Hi, I'm curious why the follow little HTML page produces "auto" for JavaScript output. I thought that getComputedStyle() was supposed to return integer px values for lengths. Is this a problem specific to firefox? Thanks, Peter
8
11273
by: John | last post by:
Hi I need a auto-number field but with a letter prefix like "P1", "P2" etc. What is the way to achieve this? Is it possible to do this at table level? Thanks Regards
1
1542
by: bubblegirl | last post by:
Hi there, i am trying to figure out if there is a way to have auto number (not 1,2,3) in access but as a prefix. For example: 1/1/2000 2/1/2000 3/1/2000 the first number as the client number the second number as today's month (in this case January)
3
2416
by: wise007 | last post by:
I HAVE A PROBLEM ON THAT..i did success on sending sms to phone and sending sms to system...n i do clear about the sms prefix the problem is i need to know how to do the SMS auto reply/auto response base on the sms prefix as an example user type "counter" send to my gsm number and system will reply with "please choose your state" i really need it urgently...huhu..please anyone who kindly cld help me on solving that problem...
5
1682
by: DruidWanderer | last post by:
I'm attempting to create a frame that loads a page with a specific variable based on a random number, but I can't seem to get it to work. Any help would be greatly appreciated. Here's what I've got so far: <html> <head> <title>Main Page</title> </head> <frameset rows="100%">
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9185
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6703
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6012
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4786
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3229
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.