473,379 Members | 1,330 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,379 software developers and data experts.

Zero Filling Autonumber Fields

I have a database where I want to use an autonumber field to make SKUs
for a new product when it is entered. Is there a way I can make the
field zero fill to a certain length? For instance, if I want the field
to be five digits in length, and I enter 123, I want the stored value to
be 00123. Is there a way I can do this? Or is there a better alternative?

Thanks.

Steve
Nov 13 '05 #1
2 2524
Steve <ra***********@hotmail.com> wrote:
if I want the field
to be five digits in length, and I enter 123, I want the stored value
to be 00123. Is there a way I can do this? Or is there a better
alternative?


Hi Steve.

An AutoNumber field should be used only for system purposes, ie for the
generation of a PK for indexing and joining to another table. Most
developers will hide the PK/FK fields from users since they have no meaning
to them. Also, AutoNumber discards 'dirty' numbers, whether or not you
save the record, and so is not necessarily sequential.

I think you need to devise a custom sequential auto-numbering system, which
will require a little VBA code.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #2
Steve wrote:
I have a database where I want to use an autonumber field to make SKUs
for a new product when it is entered. Is there a way I can make the
field zero fill to a certain length? For instance, if I want the field
to be five digits in length, and I enter 123, I want the stored value to
be 00123. Is there a way I can do this? Or is there a better alternative?

Thanks.

Steve


? format(123,"00000")
00123

If you want to zero fill and store the value in a table then make sure
the field is Text.

Here's another method.
? right("0000000000" & 123,5)
In this case, I string a bunch of zeros in front, concatenate the zeros
to 123 and end up with 00123 by extracting the last 5 characters.

Nov 13 '05 #3

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

Similar topics

1
by: John | last post by:
Hi I have linked a master and a detail table in a 'make-table' query. Both tables have their own autonumber id fields. I am getting the 'Resultant table not allowed to have more than one...
5
by: JW | last post by:
Hi, This is really weird... I have a database that has an autonumber field. Records 1-70 were deleted. Various things have changed to the front end and a few extra fields added to the table. ...
3
by: Ilan Sebba | last post by:
I have a 'supertype' table with only one field: autonumber. Call this table the 'parent' table. There are two subtypes, 'androids' and 'martians'. Martian have only one thing in common: they give...
3
by: Danny | last post by:
I am doing the TransferText method to import a tab delimited file. I am using a saved specification. DoCmd.TransferText acImportDelim, "myinputspec", "tblnames", File, True no autonumber ID is...
35
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
1
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
1
by: jason.teen | last post by:
Hi, Curerntly I have designed my table in MS Access with a column of "RuleID" and is set to (autonumber) tblRule: RuleID | Name ------------------------------- 1 ...
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.