Results 1 to 5 of 5
  1. #1
    Bigz132 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    3

    AutoNumber issue

    So I am taking a DB class at my school and we are supposed to resolve a M:M relationship with a third table. Easy enough I understand how to do that however the third table is supposed to have just the primary keys from each table and they are both auto numbers. This is creating issues because apparently a table can't have 2 autonumbers. How do i resolve this issue




    Thanks for the help

    Grant

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The third table fields would not be autonumber type, they would be number (integer) type and will store the values of the autonumber fields from the other 2 tables. This establishes an association between records of the two 'lookup' tables.

    The third table can have an autonumber field but it serves no role in relating records of the other two tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Bigz132 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2014
    Posts
    3
    So I just choose to not enforce integrity? Or can i enforce that and change the types? Thanks for the response. Huge project this weekend and small things like this keep taking up all my time.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The types in third table must be changed to number, not autonumber.

    Enforce relational integrity if you want.

    However, I suggest you set the two fields as a compound index (not compound primary key) to prevent duplicate pairs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  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,726
    Watch this free video.

    Regarding the junction table.
    It can have its own autonumber PK (recommended)
    Or it can have a compound PK made up of the keys of the other two tables. In the junction table these would be Number (Long Integer) data types.

    If you go with a separate autonumber PK, then the keys of the other 2 tables would be combined to make a unique compound index. As June said, the unique compound index will prevent duplicate records.

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

Similar Threads

  1. Autonumber issue
    By Jayfaas in forum Access
    Replies: 5
    Last Post: 08-29-2014, 01:41 PM
  2. Replies: 4
    Last Post: 11-21-2013, 05:06 PM
  3. Replies: 22
    Last Post: 05-21-2013, 07:54 PM
  4. Using AutoNumber to issue specific numbers
    By capnpat in forum Access
    Replies: 8
    Last Post: 04-13-2011, 03:57 PM
  5. Access DB issue with autonumber
    By cusfirstadmin in forum Forms
    Replies: 1
    Last Post: 12-02-2010, 10:45 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