Results 1 to 4 of 4
  1. #1
    rgg is offline Novice
    Windows 10 Access 2013
    Join Date
    Jan 2016
    Posts
    1

    Relationship not working


    First, I am a beginner at Access, done it for awhile but always trying to learn more.
    I have created a database in Access 2013 that tracks different parts of a project for the construction of towers. The main table is "tblSites" with many related tables, the primary key for most tables is "Site Number". I have created many working relationships to some of the tables and they are working fine. I recently wanted to add a table called "tblNTP" and have a relationship with "tblSites" with the primary key for both being the field "Site Number". I have been unable to determine why the relationship is not working and I have a sore forehead, hoping that a different set of eyes sees something that I am missing. I have attached screen shots that I hope will explain any questions you might have.
    Thank you for any assistance in advance!!
    Attached Thumbnails Attached Thumbnails Realtionship2.jpg   sites.png   ntp.png  

  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,892
    If [Site Number] is defined as primary key in both tables then this must be 1-to-1 relationship. Really, PK should be in only 1 side of the relationship and the other side is FK. The FK can have an index set with Duplicates No.

    What does 'not working' mean - what happens when you try to set the link? Can't see anything in images to explain cause. Is there already data in the tables?


    Advise no spaces in naming convention.
    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
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    yeah to reiterate J7: SiteNumber should only be the Primary Key in the tblSites. Un-designate it as a key in all the others. All the other tables should have an autonumber field as their primary key even if there is a 1:1 to tblSites.

    Developers have different philosophies to some degree. I myself only use autonumber as primary key for all tables - with the exception of what I call 'Lists' tables such as the list of USA States. List tables are static typically and have no autonumber nor key. If a client insists they will have a unique field in a table - that is fine, it can exist too. They are welcome to think of their field as the key field but in truth the relationships between autonumber fields exists entirely behind the scenes. The advantage of this is that some months (years) later when they change that philosophy the key/relationships are not jeopardized nor a barrier to their flexibility.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    rgg,

    My advice to you is to learn some database concepts before jumping too deeply into Access.
    A Primary key is specific to a table. The same PK would not apply to several tables. As June7 and NTC have advised, do not have embedded spaces in field or object names.(It will lead to syntax errors sooner or later).

    For your own benefit, watch the 8 part video series on Database by Dr. Daniel Soper that starts here.

    Review and apply data modelling to your situation. It will make development more streamlined than trial and error.
    Good luck.

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

Similar Threads

  1. Working query stops working after importing
    By Abacus1234 in forum Import/Export Data
    Replies: 3
    Last Post: 10-25-2015, 09:12 PM
  2. Replies: 14
    Last Post: 04-22-2015, 06:57 PM
  3. Replies: 3
    Last Post: 03-19-2015, 05:26 PM
  4. Relationship not working as it should
    By Clems in forum Database Design
    Replies: 4
    Last Post: 04-22-2013, 09:43 AM
  5. Replies: 3
    Last Post: 01-29-2013, 04:34 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