Skip to main content
Engineering LibreTexts

11.1: Forms Involving Multiple Tables

  • Page ID
  • In chapter 3 we created simple forms for single tables. A very useful form is one where the user can interact with data that comes from more than one table. We will consider how this can be done in cases where two tables are related by a one-to-many relationship.

    We will illustrate creating such a form using the form wizard. As you will see the form wizard will create a form and a subform. These two forms will have a connection established based on related fields: a primary key and a foreign key.

    Consider the Company database:

    1. If the one-to-many relationship between Department and Employee does not exist, then create this now. Note that this is Exercise 1 in Chapter 5. After doing this you should have the relationship as shown:
      Department and Employee relationship.
    2. Use the Create tab and create a form using the Form Wizard. Select all fields from the Department table:
      Form Wizard with Department table.
    3. Do not click Next or Finish, instead choose the Employee table and select all of its fields and now the Selected Fields component shows fields from both tables:
       Form Wizard with Employee table.
    4. Now, click Next and MS Access asks you how the data should be viewed:
      Form Wizard view options.
    5. We want the data displayed “by Department” and we want MS Access to use “Form with subform(s)” so you can select Next and MS Access will let you choose a layout. Choose Datasheet Layout. Click Next and MS Access will ask you to name the form – name the form EmployeesByDepartment and name the subform EmployeesSubform:
       Form Wizard final screen.
    6. Click Finish. MS Access will display the finished form called EmployeesByDepartment – see below. Experiment with the form: notice the two sets of navigation buttons - one that controls the department being viewed, and the other that controls the view of the department’s employees.
       EmployeesByDepartment form.


    Exercise \(\PageIndex{1}\)

    Consider the University database. Create a form to allow a user to view courses by department.

    Exercise \(\PageIndex{2}\)

    Consider the Library database. There are two one-to-many relationships. Create a form to list the loan records for a book. Create another form to list the loan records for a member.

    Exercise \(\PageIndex{3}\)

    Consider the Orders database. This database has several one-to-many relationships. Create appropriate forms to list

    1. a customer and the customer’s orders;
    2. an order and its detail lines;
    3. a product and the order detail lines where the product is referenced;
    4. a category and the products belonging to the category.
    • Was this article helpful?