Search code examples
databasems-accessunique

Unique row in table based on two columns


I have table like shown below in MS Access

enter image description here

and as you can see line ID 9,10 are not unique based on the second and third column.

There is the realtionship enter image description here

I want to figure out somehow that only unique row can be inserted to table based on the second and third column, is that possible ?

Any tips can be helpful.

Thanks.


Solution

  • If I got it right, you should create a compound primary key based on the 3 columns.

    Read this: https://support.office.com/en-us/article/add-or-change-a-table-s-primary-key-in-access-07b4a84b-0063-4d56-8b00-65f2975e4379

    Take a look at: Set the primary key using fields you already have in Access

    Attention to step 3.

    As you data is text, be careful that user will select this by drop-down or radio buttons instead of typing in order to avoid duplicated rows by user mistyping.