Results 1 to 5 of 5
  1. #1
    Canadiangal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2009
    Posts
    81

    Form from 2 tables


    I created a form which updates two tables. My problem is that my ID number in the employee table is an autofill; however, my ID in my related table is not. It is a one to many relationship.
    One employee to many tasks in the Task table. In my form I have chosen the Employee ID not the Task employee ID. When I enter into the form a task for an employee(that has already been created) then everything updates correctly. However, if I want to enter a task for an employee that is not in that table, I would like the ability to still create the ID from the form. The only solution I can think of is to have two separate forms. Is there a way to create a new record in the employee table from the form.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You're talking about a one-to-many relationship, which is to say a Parent-Child relationship, and you should never create an orphan Record, i.e. one without a 'Parent!' Why would you want to?

    Two separate Forms is the only way to go! You then add a Subform to your Main Form (or One-side) using the Many-side Form as the basis of the Subform.

    You will then have the a single 'form' in front of you, be able to update both Tables, and Access will automatically take care of linking them!

    But you will still need a Parent Record before you can create a Child Record, as it should be!

    Linq ;0)>

  3. #3
    Evilferret is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    27
    If you're comfortable doing some VBA code, you could link the input boxes on the form to a temporary table. When the user confirms the data submission you can then read the data from the temp table and query your Employees table to check if the EmployeeID already exists.

    If the EmployeeID exists, use that ID in writing records to the Tasks table.
    If the EmployeeID does not exist, you first create a new employee record, then use that ID in writing records to the Tasks table.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    That's a long way to go, especially when one-to-many relationships should really be displayed in a Main Form/Subform configuration!

    Linq ;0)>

  5. #5
    Canadiangal is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2009
    Posts
    81
    That is the point, I don't want to create an orphan record, but I want the ability to create the task and have it generate an employee record if that employee doesn't exist. It should then take you to the employee table to enter that information. I also don't want all the information from both tables in the form. I'm at a loss as how to do this. Any help would be appreciated.

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

Similar Threads

  1. Two Tables, One Form
    By imintrouble in forum Forms
    Replies: 7
    Last Post: 02-03-2012, 01:23 PM
  2. Replies: 14
    Last Post: 01-26-2012, 02:20 AM
  3. 1 Form ~ 2 Tables
    By cvansickle in forum Forms
    Replies: 0
    Last Post: 03-01-2011, 04:59 PM
  4. Two tables, one form
    By Remster in forum Forms
    Replies: 26
    Last Post: 11-10-2010, 05:24 AM
  5. Replies: 9
    Last Post: 03-24-2009, 09:19 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