Results 1 to 6 of 6
  1. #1
    Alico is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    5

    Problem with table relationships - Foreign Key and Primary Key

    Hi,

    I'm a newbie with access, and I have a problem understanding table relationships.

    My application is a single session where I want user to input some data in forms. The data are basically checklists for a single job, but I want to logically separate them in forms or tabs. All data should be related to the Job ID that he enters in the first form.

    I tried to separate the tables based on the tabs with the primary key in the first table as "Job ID", but I don't want the user to enter the "Job ID" in every form, just once and it should update the foreign key in the other forms. But this doesn't happen.

    Is what I'm asking possible? or am I doing something wrong?

    Thanks for your time & help.

    Regards,
    Ali

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Are you using form/subform arrangement? Have you set the Master/Child Links properties of the subform container control? Review: http://office.microsoft.com/en-us/ac...010098674.aspx
    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
    Alico is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    5
    My problem is, I want the user to enter the primary key "Job ID" only once, and the foreign key in all other tables should create a new record with this value automatically.

    What I understand is that the master/child and subforms works only when you already have the data in the other tables.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    No, that is not the case. The Master/Child Links will cause the PK of the main form to be saved as foreign key in the subform record. That's a primary purpose behind the form/subform arrangement.

    JobID is not an autonumber field?
    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
    Alico is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    5
    Quote Originally Posted by June7 View Post
    No, that is not the case. The Master/Child Links will cause the PK of the main form to be saved as foreign key in the subform record. That's a primary purpose behind the form/subform arrangement.

    JobID is not an autonumber field?
    The JobID is a number entered by user not auto, so my problem is it doens't transfer aytomatically and the user have to input it again. I want to be able to copy this number from master to child.

    Is there a way I can copy the PK to FK?

    Thanks,
    Ali

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Doesn't matter if the primary key is auto or user input. If the field is defined as primary key in table and form/subform arrangement properly set up, the value will automatically save into the subform record.
    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.

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

Similar Threads

  1. Primary key/ foreign key question
    By DaveG in forum Access
    Replies: 5
    Last Post: 05-02-2014, 12:42 PM
  2. Primary Key and table relationships
    By dm23 in forum Database Design
    Replies: 4
    Last Post: 07-10-2013, 04:38 PM
  3. Replies: 11
    Last Post: 06-11-2012, 12:23 AM
  4. Primary and foreign key in relationships?
    By Fatbot in forum Access
    Replies: 1
    Last Post: 04-12-2011, 10:11 AM
  5. Primary/foreign keys + relationships
    By tripptofer in forum Database Design
    Replies: 0
    Last Post: 08-12-2009, 07:44 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