Results 1 to 4 of 4
  1. #1
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    81

    Relating tables so records match

    I'm a beginner at access and I feel like this should be incredibly easy, but I cannot figure it out. I have a master table with employee names, address, dob, etc. that I want to somehow link to another sheet that has information regarding their schedule and days off. I have set the primary key as "auto number" for each table and tried to create a referential relationship between the two id numbers. The problem I believe I am running into is that there are more IDs in the employee table than the days off table (the days off is currently blank). Is there a way for me to tell access to auto populate a record in the days off sheet for every record in the master employee sheet? I want it to do this without me having to type the employee name twice (once in each sheet) to eliminate redundancy.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    The schedule table can have it's own autonumber primary key, but it would not be the field that related to the master table. You'd have another field that would have the master table's ID field in it, which would be a called a foreign key in the schedule table. The data type of that field in the schedule table would be Number, field size Long Integer.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Cannot set PK/FK link between two autonumber fields. Set the EmployeeID FK field in schedule table as a number type.
    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.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Y'all type too fast.....

    I understand that you want to JOIN two tables so you can query the relative data.

    I do not understand any of your needs beyond that.

    In your table with the Schedule and days off you will need a Foreign Key in a addition to said table's Primary Key (Autonumber). This Foreign Key Field will store the value from the other table's relative Primary Key field.

    If the 5th record/row in your master table has a PK field and its value is 5, you would store the Long Integer 5 in the associated table's FK field. Anywhere, within your schedules table, there is a record/row that is relative to the 5th record in your main table, the FK field's value will be 5.

    Multiple records in your schedule table that has an FK field with a value of 5 will create a one to many relationship.

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

Similar Threads

  1. Replies: 11
    Last Post: 02-06-2014, 10:05 PM
  2. Relating Tables
    By Jabirali in forum Database Design
    Replies: 4
    Last Post: 12-06-2012, 03:59 AM
  3. Need help relating tables
    By LeahJB in forum Database Design
    Replies: 4
    Last Post: 02-15-2012, 08:37 AM
  4. Still struggling with relating tables
    By djclntn in forum Database Design
    Replies: 31
    Last Post: 02-14-2012, 02:08 PM
  5. Might someone help with relating some Tables?
    By djclntn in forum Database Design
    Replies: 20
    Last Post: 02-08-2012, 11:35 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