Create primary key with pre-defined prefix

C

CLU73

I was wondering if there was a way to create a primary key with a pre-defined
prefix. For instance. I would like my primary key to be FF### where FF
would be the start for all the primary keys in this particular table and then
the ### would represent the rest of the primary key.

Can anyone tell me how to do this?
 
O

Ofer

I think that the easiest way will be to create a table with ID (AutoNumber)
and then create a query on each table adding the prefix

Select "FF" & [ID_Field] As NewId From TableName

That way you can avoid extra programming, as to calculate the next key

Good Luck
 
J

Jeff Boyce

If every row will have the same prefix, you don't need to save the prefix.
Create a query that returns the primary key and concatenate (i.e., pre-pend)
your 'constant' (e.g., "FF"). Use the query as a source rather than
directly using the table.

I may be reading too much into your post, but it seems to imply that you
wish to do this with other tables as well. Do you have multiple tables that
store similar data, but with differing tablenames? For example, it might be
that you have an "AA" table, and a "BB" table, ... and an "FF" table, all of
which have the same data fields. If so, you have a spreadsheet, not a
relational database, and there are much better ways to get at Access'
functionality.
 
Top