Results 1 to 5 of 5
  1. #1
    ksammie01 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    13

    Changing primary keys

    Ok, so i have a database, with very many tables, forms and queries.
    In the initial database design, i used the id auto generated, which auto increments, as the primary key, and then created all the forms and queries, and these all work fine.
    The needs have changed, and now i want to change the primary key in one of the tables, from the auto id, to something else, still unique though.
    Am not quite sure, what the effect of this will be on the forms and queries.
    Is it ok for me to change the primary key?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would have to ask why? You can have any field a unique/no duplicates without it being a PrimaryKey.

  3. #3
    ksammie01 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    13
    Ok, maybe i should throw more light on the database application. Its for an organization that supports children. the children have sponsors.
    so, the sponsors were first identified by the auto generated key, then the organization wants now to use the sponsors PRN(payment reference number), which the sponsors use to send the money, as the primary key.
    hope it explains why i want to change the sponsors primary key from the auto key to the prn number.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can still use the "sponsors PRN" without changing the PrimaryKey. The two will probably go hand in hand.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    As Allan has said, these are really independent things.

    If you want a field for your or sponsors' use to identify records, then put in the field with a unique index.

    Access is quite content with the unique autonumber as PK. These things can coexist.

    An old rule says --never change the PK. There have been cases where PKs (built upon some local identifier) have had to be changed because the scope of the database at design time, or through merger etc, was underestimated. That is why many use an autonumber ( or sequence in some dbms) as the table's PK.

    Good luck with your project.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. primary keys in four different tables
    By greatlhanderz_15 in forum Access
    Replies: 5
    Last Post: 01-30-2013, 10:04 PM
  2. Primary Keys & Relationships
    By Njliven in forum Programming
    Replies: 4
    Last Post: 12-17-2012, 09:42 AM
  3. How to create two primary keys
    By Shabana123 in forum Database Design
    Replies: 1
    Last Post: 09-08-2012, 05:55 AM
  4. Multiple primary keys
    By elektrisk in forum Access
    Replies: 5
    Last Post: 02-11-2010, 04:39 PM
  5. Primary and Secondary Keys...
    By LittleOleMeDesigns in forum Database Design
    Replies: 5
    Last Post: 07-24-2009, 11:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums