Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2008

Tip: Looking for answers? Try searching our database.

primary key

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB - 28 May 2008 21:21 GMT
Hello
Would it be possible to make the primary key of a table which is AutoNumber,
have or start with 3 digits?
Instead of 1 can I make it to show 001 then 002 and so on?
Thanks
Klatuu - 28 May 2008 21:55 GMT
That would be incorrect use of an autonumber field.
Autonumber fields should never be seen or used for any meaningful data.
Their sole purpose is for surrogate primary keys and as a value to assign to
child records as a foreign key.   The value of any field, variable, or
control can be presented with leading zeros using the Format function.

Additionally, you cannot expect a continuous unbroken sequence of numbers
with an autonumber field.  There will be gaps caused by a user beginning a
record, but canceling or undoing the record before it is actually written to
the table. The number is assigned as soon as the first character is typed
into the first control on a form and whether the record is saved or not, the
number is consumed and will not be reused.

Please explain what you are wanting to do and perhaps we can help with the
how to do it.
Signature

Dave Hargis, Microsoft Access MVP

> Hello
> Would it be possible to make the primary key of a table which is AutoNumber,
> have or start with 3 digits?
> Instead of 1 can I make it to show 001 then 002 and so on?
> Thanks
>  
JB - 28 May 2008 22:26 GMT
Yes actually you've got a point.
I wanted the number to have more digits only because when I ran the report,
the OrderId number being 1 or 2 etc, seemed too insignificant. Having the
leading zeros just made it look better.
But reading what you said, I'm maybe being a tad too picky.
Thanks for the explanation though
J

> That would be incorrect use of an autonumber field.
> Autonumber fields should never be seen or used for any meaningful data.
[quoted text clipped - 21 lines]
>> Instead of 1 can I make it to show 001 then 002 and so on?
>> Thanks
Klatuu - 28 May 2008 22:54 GMT
If you need a sequential numbering system for an Order Number and you want it
to start with 3, here is a way to do that:

   Me.txtOrderNumber = Nz(DMax("OrderNumber","tblOrderHeader"), 2) + 1

And when you want it to show 3 numbers long use the Format property of the
control where you display it as 000

Now, there are a couple of issues.  If you have multiple users entering
orders, it is possible they can both get the same number if they haven't
saved the new order yet. But there are a number of techniques for doing that.
Signature

Dave Hargis, Microsoft Access MVP

> Yes actually you've got a point.
> I wanted the number to have more digits only because when I ran the report,
[quoted text clipped - 29 lines]
> >> Instead of 1 can I make it to show 001 then 002 and so on?
> >> Thanks
??? - 29 May 2008 02:23 GMT
sdf

> Hello
> Would it be possible to make the primary key of a table which is
> AutoNumber, have or start with 3 digits?
> Instead of 1 can I make it to show 001 then 002 and so on?
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.