Microsoft Access Training

Advanced Form Features

Learn to add calculated text boxes to forms and display related records with subforms.

Start here

Overview

This lesson enhances the Trips form with a calculated Trip Length control and then embeds the trips form as a subform within the Clients form.

What You Will Learn

  • Create a tabular form with the Form Wizard.
  • Modify labels and text boxes in Design View.
  • Add an unbound text box.
  • Enter a calculated expression in a Control Source.
  • Format a calculated control.
  • Create and save a supporting form.
  • Insert an existing form as a subform.
  • Display and enter related records through a main form and subform.

Before You Begin

  • Creating and using forms
  • Form Design View
  • Table relationships
  • Calculated expressions

Why This Matters

Calculated controls display useful information without storing redundant values, while subforms let users work with related one-to-many records from a single form.

Plan Your Study

  • Create FrmTrips with the Form Wizard.
  • Modify its layout in Design View.
  • Add the Trip Length calculated text box.
  • Test the calculation in Form View.
  • Create FrmAgents.
  • Open FrmClients in Design View.
  • Insert FrmTrips as a subform.
  • Enter a related trip through the combined form.

Next step

Read the complete chapter.

The Learn tab contains the written lesson from Surviving Statistics.

Go to Learn

Written lesson

Learn Advanced Form Features

Learn to add calculated text boxes to forms and display related records with subforms.

Advertisement

Advanced Form Features

Much of the power in an Access database comes when you intitally set it up. One of the essential elements of proper database design is understanding how to use Access' Form Features. This lesson will step you through using the more advanced form features that Access has to offer.

Advanced Form Features

1. If it is not already open, open the No Fault Travel database.

2. Use the form wizard to create a form based on all the fields in TblTrips. Choose a Tabular form layout. Name the form FrmTrips.

3. Modify the labels and text boxes so the form appears as the one below in Design View.

Microsoft Access lesson screenshot 6thLesson1

Remember not to change the text in the text boxes. The text boxes must refer to the fields in the table. Use the ruler shown in the image as a guide. Increase the size of the text boxes to properly display the dates. You will use the blank space between the return date and cost field to add a calculated field in the next portion of this lesson.

4. Switch to Form View. Make sure it resembles the one below.

Microsoft Access lesson screenshot 6thLesson2

5. Return to Design View of this form.

We will now add a calculated field to this form. Ideally, most calculations should be performed in a query so they can be used, if desired, in multiple forms or queries. However, if you only need to use a calculated field on one form or one report, Access allows you to do this. 

Creating a new text box

To create a field that computes values in a form you will need to create a new text box. This text box, instead of being bound to a field in the table or query, will compute a value based on the expression you enter into it.

Microsoft Access lesson screenshot 6thLesson3

6. Locate and click the Text Box tool in the Controls group.

When you create a text box, the text box will appear at the location of the mouse pointer when you click. The label will appear to the left of the text box (in columnar form, not tabular). You will need to move the label and resize and position the text box.

7. Move the mouse pointer just to the right of the ReturnDate text box and click.

Microsoft Access lesson screenshot 6thLesson4

A new text box containing the text “Unbound” should appear where you clicked the mouse. The term unbound lets you know that as of now, this text box does nothing. It is not bound to a field from the table or a calculation.

A label for this text box should also appear to the left of the text box.

8. Carefully click on and then delete the label for the new text box.

9. If needed, reposition the new text box so if fits nicely between the text boxes for the return date and cost fields.

Since you deleted the label Access created for the new text box, you will have to add one yourself. You will do this by copying the existing label for trip cost. After copying it, you will need to reposition it and change the text it displays.

10. Carefully select just the label for the Cost field and click the Copy tool on the Home tab.

The copy and paste commands can also be executed by using the shortcut keys Control+C and Control+V or by right-clicking to open the shortcut menu.

11. Now execute the Paste command and move the copy of the label above the Unbound text box.

Microsoft Access lesson screenshot 6thLesson5

You will need to change the size of the Form Header. If so, you can click and drag the top of the Detail bar to shorten the Form Header.

12. Change the text on the copied label to read Trip Length.

You will now enter a formula into the text box to compute the length of the trip.

Entering formulas in a text box

To have a text box compute a value, you must enter a formula into the control source of that box. While you can simply click in the text box and type the formula, you will often want to do this using the Property Sheet for the text box. Since you may also want to change the format of the computed value to, for example, currency, you will need to change the box’s properties eventually. When creating a formula using the Property Sheet, you enter the formula in the Control Source row, located on the Data tab.

1. Select the Unbound text box and display its properties.

Text box properties can be accessed using the ribbon or shortcut menu. On the ribbon’s Design tab, the Property Sheet tool is located in the Tools group. You can also right-click the text box and choose Properties from the shortcut menu.

Microsoft Access lesson screenshot 6thLesson6

2. On the Property Sheet, display the Data tab. In the Control Source row, type =[ReturnDate]-[DepartureDate].

Notice this formula begins with an equals sign. The equals sign is needed for form and report calculations, but not for calculated fields in queries.

Instead of typing this formula in the space provided on the row, you could also use the Zoom dialog box or the Expression Builder dialog box to enter the formula, as we did earlier. Expression Builder will open when you click the build button in the row. The Zoom box can be opened with the shortcut keys (Shift+F2). Alternatively, either dialog box can be accessed by right-clicking in the Control Source row to open the shortcut menu.

3. Click the Format tab in the Property Sheet and change the Format property to General Number.

4. Close the Property Sheet and save the form. View the form in Form View.

Microsoft Access lesson screenshot 6thLesson7

You should see the trip length computed in the calculated field you created.

5. Close the FrmTrips form after examining it.

Creating and using subforms

When you created the lookup fields in the trips table, Access created relationships between the trips table and the destinations, clients, and agents tables. To view the relationships between tables, go to the Database Tools tab on the ribbon and click on the Relationships tool.

Microsoft Access lesson screenshot 6thLesson8

If you use the Form tool to create a new form from a table that is linked to another, Access will automatically create a subform to display the related records. For example, if you create a form based on the Agents table, Access will automatically add a subform that displays the trips that agent has booked. Likewise, if you use this tool to create a form based on Clients, Access will automatically add a subform for the trips that client has booked. In the next step, you will create a form based on the agents table.

Microsoft Access lesson screenshot 6thLesson9

1. In the navigation pane, click once on TblAgents. On the Create tab, click the Form tool.

You should see a main form for TblAgents and a subform with the linked table TblTrips.

Microsoft Access lesson screenshot 6thLesson10

2. Save this new form as FrmAgents and close it.

If existing forms are based on related records, you can combine them using the subform feature. Forms can have more than one subform. For example, if you added a payment history table to this database, you could add a subform to the clients form that displayed the trip information and another subform for payment information.

When creating forms with subforms, the main form should be columnar and the subform(s) tabular. You have already created a columnar FrmClients and a tabular FrmTrips. In the next steps, we will insert the trips form (as a subform) into the clients form. Since the tables are linked, the trips that are displayed will be related to the current client record.

3. Display FrmClients in Design View.

Microsoft Access lesson screenshot 6thLesson11

4. Carefully drag FrmTrips from the Navigation Pane to the bottom left corner of FrmClient (below the Country field).

In the clients form, notice a large control which will be the list of trips booked by the client.

Microsoft Access lesson screenshot 6thLesson12

5. Increase the height of the FrmTrips subform by approximately 1.”

You might have to first increase the height of the FrmClients form by dragging the Form Footer bar down slightly, so that you can see the bottom center sizing handle on the FrmTrips subform.

6. Save and then switch to Form View.

The client and the trips booked by that client should be visible. To browse through the client records, use the navigation buttons at the bottom of the clients form window. The navigation buttons for the trips are located on the trips subform.

Microsoft Access lesson screenshot 6thLesson13

7. Display Carrie White’s record and enter an additional trip as shown below.

Microsoft Access lesson screenshot 6thLesson14

This client can be found by browsing through the records using the navigation buttons or using the Find tool on the ribbon’s Home tab. As you can see from this portion of the lesson, subforms are a convenient way to enter and edit data.

8. Close the Clients form.

Advertisement

Next step

See the concepts demonstrated.

Continue to Watch for chapter videos and worked examples.

Go to Watch

See it explained

Watch

Choose the explanation or example that best supports your learning.

Instructional videos will be added later.

Next step

Apply what you have learned.

Use the guided questions and activities in Practice.

Go to Practice

Apply what you learned

Practice Advanced Form Features

Build a calculated control in FrmTrips and add that form as a subform within FrmClients.

Guided Practice

  • Create FrmTrips using all TblTrips fields and a tabular layout.
  • Modify the labels and text boxes to match the lesson.
  • Add an unbound text box beside ReturnDate.
  • Set its Control Source to =[ReturnDate]-[DepartureDate].
  • Format the result as General Number.
  • Create and save FrmAgents.
  • Insert FrmTrips into FrmClients as a subform.
  • Enter an additional trip for the specified client.

Challenge Yourself

  • Add another calculated control that displays trip cost per day.
  • Change the subform layout and evaluate readability.
  • Explain why Trip Length should be calculated rather than stored.
  • Verify that the subform displays only records related to the current client.

Check Your Understanding

  • Can you distinguish a bound control from an unbound calculated control?
  • Can you explain why the Control Source begins with an equals sign?
  • Can you identify the relationship that links the main form and subform?
  • Can you explain why a calculated control does not change the table design?

Next step

Save the materials you may need later.

Open Resources for the study sheet, spreadsheets, and related learning materials.

Go to Resources

Keep learning

Resources

Study sheets, downloadable files, companion tools, and related lessons for this chapter.

For educators

Teaching this chapter?

The Instructor tab contains objectives, teaching ideas, assessments, and a printable guide.

Open Instructor Resources

LutherMaddy.com — Helping Humans Learn

Advanced Form Features: Instructor Resources

Teach this lesson

Instructor Resources

Classroom-ready objectives, teaching ideas, questions, and assessment materials for this chapter.

Learning Objectives

  • Create a tabular form and modify its design.
  • Add an unbound calculated text box.
  • Set and format a calculated Control Source.
  • Create supporting forms.
  • Insert and size a subform.
  • Enter related records through a main form and subform.

Prerequisite Knowledge

  • Forms
  • Design View
  • Relationships
  • Calculated expressions

Teaching Outline

  • Create FrmTrips.
  • Modify its layout.
  • Add the Trip Length control.
  • Test the calculated result.
  • Create FrmAgents.
  • Add FrmTrips to FrmClients.
  • Enter and verify a related trip.

Key Concepts

  • Unbound controls are not directly tied to table fields.
  • Calculated controls begin with an equals sign.
  • Subforms display related records from the many side.
  • Main-form/subform links depend on relationships and matching fields.

Classroom Demonstration

  • Change a return date and show Trip Length recalculating.
  • Navigate clients and show the subform records changing.
  • Enter a trip through the subform and inspect the saved foreign key.

Questions to Ask

  • Why calculate trip length instead of storing it?
  • What relationship makes the subform work?
  • When is a subform preferable to opening a second form?

Teaching Notes

  • Verify the Link Master Fields and Link Child Fields properties.
  • Distinguish labels from calculated text boxes.
  • Use realistic dates when testing the calculation.

Assessment Ideas

  • Create the calculated Trip Length control.
  • Insert the Trips subform into Clients.
  • Enter and verify a related record.

Grading Rubric

CriterionPoints
Base form created and formatted2
Calculated control correct3
Subform inserted and sized correctly2
Main/subform relationship works2
Related record entered successfully1
Total10

Exam and Discussion Questions

Basic

  • Define an unbound calculated control and a subform.

Applied

  • Create a form control that calculates days between two dates.

Conceptual

  • Explain how a subform supports a one-to-many relationship.

Keep Exploring

Continue Learning

Explore step-by-step lessons, interactive calculators, downloadable study sheets, and practical educational resources.