Primary Key Identifier

SKV

Active Member
Joined
Jan 7, 2009
Messages
255
is there a way that let system selects the field combination to generate Primary key for that data base.

I have 50-60 fields and each has a repeating value at some point. So I want the system to check a combination of fields which can give me primary key for that data base.
 

SKV

Active Member
Joined
Jan 7, 2009
Messages
255
I can use Auto-number as I get a datapull every month in which records may be repeated.

IF I use the auto-number than during appending I will get duplicate records.




just insert an autonumber field into the table and have it be the primary key
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
If you want you can create a compound key.
In the table design control-click the fields that you want to include in the key, then click the Primary Key icon and save the table. If it can't save you already have duplicates, and will need to correct that problem before creating the key.

Denis
 

SKV

Active Member
Joined
Jan 7, 2009
Messages
255
Yeh that is a option but I want the system to select the minimum required fields to make a primary key.

If you want you can create a compound key.
In the table design control-click the fields that you want to include in the key, then click the Primary Key icon and save the table. If it can't save you already have duplicates, and will need to correct that problem before creating the key.

Denis
 

SydneyGeek

MrExcel MVP
Joined
Aug 5, 2003
Messages
12,251
You'll probably need to write some code that picks your fields (say) four at a time, concatenates them, groups and looks for duplicates. That's a huge number of permutations.
Why don't you pick the 4 most likely, concatenate and group them, and if you find any duplicates keep adding one field at a time until you get a unique set. You can then use this combo as your key fields.

Denis
 

Forum statistics

Threads
1,082,151
Messages
5,363,430
Members
400,736
Latest member
Aida

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top