Prefix for primary key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am designing a table that will have a primary key with a prefix like "REC#####" . where "#" are autonumbers. However, I wish to start the numbers at, say, 10015 and then go on ascendingly.

I'm pretty sure I did this before without much fuss but can't remember--pretty bad since it was yesterday.

Can anyone point me in the right direction.
 
ML,

I'll give it a whirl tonight when I get home, but the article looks good.

Could have sworn that I did something in Default Value or Input Mask; maybe it wasn't a primary key and/or autonumber field that I was working. The KB article declaring that autonumber will only start at 1 or 1 above the last number seems rather definitive.

Will get back to you guys on this...
 
Hi Alcide,

The Autonumber type is provided for the sole purpose of generating unique
values for use as Primary Keys. Any other use will likely lead to problems
later. The fact that you are looking to doll up the autonumber with a
prefix kind of implies that humans will see the thing you are generating.
Much better that you generate your own sequence and manage it according to
your needs.

You might go to www.mvps.org/access and see what they have to say about
autonumbers.

HTH
--
-Larry-
--

Alcide said:
Hello,

I am designing a table that will have a primary key with a prefix like
"REC#####" . where "#" are autonumbers. However, I wish to start the numbers
at, say, 10015 and then go on ascendingly.
I'm pretty sure I did this before without much fuss but can't
remember--pretty bad since it was yesterday.
 
you can make a insert query with the desired starting number to start of
where you want ...

HTH

Pieter

Alcide said:
ML,

I'll give it a whirl tonight when I get home, but the article looks good.

Could have sworn that I did something in Default Value or Input Mask;
maybe it wasn't a primary key and/or autonumber field that I was working.
The KB article declaring that autonumber will only start at 1 or 1 above the
last number seems rather definitive.
 
Hello Larry et. al.,

Based on the feedback I think I am going to give up on trying to prefix an autoumber. Perhaps the thing to do is to set a text field to a default value as a prefix and then increment the number part of the field.

I'm going to try to work it out and post the result in a new thread.

Thanks for the cerebral workout.
 
Guess I only picked up on half of your question, setting the starting point
of an auto number.

I missed the point you wanted to *add* something to it.

As you're probably discovering, that can't be done. You need to "roll your
own."

Take a look at
http://support.microsoft.com/default.aspx?scid=kb;en-us;210194.

I've used code similar to this to make all kinds of composite auto numbers.

Good luck.

Sco

Alcide said:
Hello Larry et. al.,

Based on the feedback I think I am going to give up on trying to prefix an
autoumber. Perhaps the thing to do is to set a text field to a default
value as a prefix and then increment the number part of the field.
 
Back
Top