Results 1 to 4 of 4
  1. #1
    bonecone is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Posts
    25

    Question one-to-one relationships

    I'm a bit rusty with Access and can't figure out what I'm doing wrong.

    I have three tables

    Staff Data
    Salary Data
    Vacation Data

    The ID field of Staff data has a one to one relationship with the ID field of Salary data. The ID field of Salary Data has a one-to-one relationship with the ID field of Vacation Data.

    When I enter a record directly into the Staff Data table I am given a plus sign that I can click on to enter a record into the Salary Data table for this staff member. Presumably once I fill out these fields I should be given another plus sign I can click on to fill out the fields in the Vacation Data table.

    However, when I key in the Salary Data fields and try tabbing to the next cell I get an error message saying



    "You cannot add or change a record because a related record is required in table 'Staff Data'"

    What am I missing here?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If these are all 1-to-1 why separate tables? How many fields? Will all staff always have data in Salary and Vacation?

    Are you the only user of this project? Forms would be better interface for data entry than directly with 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
    Jacqueline is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    12
    Your thoughts on design are correct. A good rule of thumb is if you change subjects you create a new table. This keeps the need to enter redudant data out of your database.

    Having said that, it sounds like you are doing data entry directly into the table, you can only have one sub (the plus sign) table connected at a time.

    Also, I think you are going to run into problems with the Vacation table. You will have one Employee table but the Vacation would logically be a Many table. The Employee will take many vacation days.

    Change that to a many table by using the Auto number to create a primary key where the Employee ID is the Foreign Key in the Vacation table.

    Hope this helps
    Jacqueline

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Good points Jacqueline.

    Whether or not these tables should be separate depends on what they are for.

    OP said relationships are 1-to-1. If Salary is just a single record for the staff current salary, then that is info about the staff. Every staff has a salary so just put field in Staff table for the salary amount. If Vacation is a single record for the staff vacation category, again, info about staff, put in Staff table.

    If Salary and Vacation are intended to document history of staff salary and vacation earned/used, then they are 1-to-many relationships and separate tables are needed.

    Really need more info.
    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. Replies: 15
    Last Post: 01-04-2012, 05:03 PM
  2. Relationships I think
    By darlaj5 in forum Access
    Replies: 2
    Last Post: 05-04-2011, 08:37 PM
  3. One to One Relationships
    By ketbdnetbp in forum Database Design
    Replies: 1
    Last Post: 04-27-2011, 11:22 AM
  4. Relationships again
    By BarbT in forum Access
    Replies: 2
    Last Post: 11-09-2010, 04:12 AM
  5. One to many relationships
    By CoachBarker in forum Database Design
    Replies: 1
    Last Post: 09-13-2010, 09:01 PM

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