I have an Access database that I am trying to create. I want to use two columns from the table to create the primary key.
Projectbl (ProjectID, ProjectRegion, other columns)
I want the ProjectID to autoincrement. That's fine. So far whenever I add a new project, the ProjecID increments by itself.
I want to create a new column in that same table that will be the ProjectRef where the new number would be a composite of ProjectID and ProjectRegion.
So for example
ProjectID ProjectRegion OtherCol
---------------------------------
1 500 ...
2 100 ...
3 200 ...
4 500 ...
5 500 ...
6 100 ...
I want the table to actually look like that
ProjectRef ProjectID ProjectRegion OtherCol
--------------------------------------------
5001 1 500 ...
1002 2 100 ...
2003 3 200 ...
5004 4 500 ...
5005 5 500 ...
1006 6 100 ...
So I am trying to add a new project: the projectID will autoincrement to 7, but the ProjectRef will be 'ProjectReg'7 whatever the ProjectReg is.
I know I can create a composite key with
CREATE TABLE 'Projectbl'
(
ProjectID INT(10) NOT NULL AUTO_INCREMENT,
ProjectRegion INT(10) NOT NULL,
other columns VARCHAR(100),
CONSTRAINT ProjectRef
PRIMARY KEY ('ProjectRegion', 'ProjectID')
)
How can I actually display ProjectRef in the table?