Create a form

A form is a database object that you can use to enter, edit, or display data from a table or a query. You can use forms to control access to data, such as which fields or rows of data are displayed. For example, certain users might need to see only several fields in a table with many fields. Providing those users with a form that contains just those fields makes it easier for them to use the database. You can also add buttons and other functionality to a form to automate frequently performed actions.

Think of forms as windows through which people see and reach your database. An effective form speeds the use of your database, because people don't have to search for what they need. A visually attractive form makes working with the database more pleasant and more efficient, and it can also help prevent incorrect data from being entered. Microsoft Office Access 2007 gives you new tools to help you create forms quickly, and provides new form types and features that improve the usability of your database.

 Note   This article assumes you have already created a table (or a query based on one or more tables), and that you want to build a form to view or manipulate the data. For more information about tables and queries, see the links in the See Also section of this article.

What do you want to do?


Create a form by using the Form tool

You can use the Form tool to create a form with a single mouse-click. When you use this tool, all the fields from the underlying data source are placed on the form. You can begin using the new form immediately, or you can modify it in Layout view or Design view to better suit your needs.

Use the Form tool to create a new form

  1. In the Navigation Pane, click the table or query that contains the data you want to see on your form.
  2. On the Create tab, in the Forms group, click Form.

Access Ribbon Image

Access creates the form and displays it in Layout view. In Layout view, you can make design changes to the form while it is displaying data. For example, you can adjust the size of the text boxes to fit the data, if necessary. For more information about form views, see the Understand Layout view and Design view section.

If Access finds a single table that has a one-to-many relationship with the table or query that you used to create the form, Access adds a datasheet to the form that is based on the related table or query. For example, if you create a simple form that is based on the Employees table, and there is a one-to-many relationship defined between the Employees table and Orders table, the datasheet displays all the records in the Orders table that pertain to the current Employee record. You can delete the datasheet from the form if you decide you do not need it. If there is more than one table with a one-to-many relationship to the table that you used to create the form, Access does not add any datasheets to the form.

Top of Page Top of Page

Create a split form by using the Split Form tool

A split form is a new feature in Microsoft Office Access 2007 that gives you two views of the data at the same time — a Form view and a Datasheet view.

Split form

The two views are connected to the same data source and are synchronized with each other at all times. Selecting a field in one part of the form selects the same field in the other part of the form. You can add, edit, or delete data from either part (provided that the record source is updateable, and you have not configured the form to prevent these actions).

Working with split forms gives you the benefits of both types of forms in a single form. For example, you can use the datasheet portion of the form to quickly locate a record, and then use the form portion to view or edit the record.

To create a split form by using the Split Form tool:

  1. In the Navigation Pane, click the table or query that contains the data that you want on your form. Or open the table or query in Datasheet view.
  2. On the Create tab, in the Forms group, click Split Form Button image.

Access creates the form and displays it in Layout view. In Layout view, you can make design changes to the form while it is displaying data. For example, you can adjust the size of the text boxes to fit the data, if necessary. For more information about form views, see the Understand Layout view and Design view section.

For more information about creating and working with a split form, see the article Create a split form.

Top of Page Top of Page

Create a form that displays multiple records by using the Multiple Items tool

When you create a form by using the Simple Form tool, the form that Access creates displays a single record at a time. If you want a form that displays multiple records but is more customizable than a datasheet, you can use the Multiple Items tool.

  1. In the Navigation Pane, click the table or query that contains the data you want to see on your form.
  2. On the Create tab, in the Forms group, click Multiple Items Button image.

Access creates the form and displays it in Layout view. In Layout view, you can make design changes to the form while it is displaying data. For example, you can adjust the size of the text boxes to fit the data. For more information about form views, see the Understand Layout view and Design view section.

When you use the Multiple Items tool, the form that Access creates resembles a datasheet. The data is arranged in rows and columns, and you see more than one record at a time. However, a Multiple Items form gives you more customization options than a datasheet, such as the ability to add graphical elements, buttons, and other controls. For more information about customizing your form, see the sections Fine-tune your form in Layout view, Fine-tune your form in Design view, and Add controls to your form.

Top of Page Top of Page

Create a form by using the Form Wizard

To be more selective about what fields appear on your form, you can use the Form Wizard instead of the various form-building tools previously mentioned. You can also define how the data is grouped and sorted, and you can use fields from more than one table or query, provided that you specified the relationships between the tables and queries beforehand. For more information about creating relationships, see the links in the See Also section of this article.

  1. On the Create tab, in the Forms group, click More Forms, and then click Form Wizard Button image.
  1. Follow the directions on the pages of the Form Wizard.
    1.  Note   If you want to include fields from multiple tables and queries on your form, do not click Next or Finish after you select the fields from the first table or query on the first page of the Form Wizard. Instead, repeat the steps to select a table or query, and click any additional fields that you want to include on the form. Then click Next or Finish to continue.

  2. On the last page of the wizard, click Finish.

Top of Page Top of Page

Create a form by using the Blank Form tool

If the wizard or the form-building tools don't fit your needs, you can use the Blank Form tool to build a form. This can be a very quick way to build a form, especially if you plan to put only a few fields on your form.

  1. On the Create tab, in the Forms group, click Blank Form Button image.

Access opens a blank form in Layout view, and displays the Field List pane.

Field List pane

  1. In the Field List pane, click the plus sign (+) next to the table or tables that contain the fields that you want to see on the form.
  2. To add a field to the form, double-click it or drag it onto the form. To add several fields at once, hold down CTRL and click several fields, and then drag them onto the form at the same time.

 Note   The order of the tables in the Field List pane can change, depending on which part of the form is currently selected. If you are not able to add a field to the form, try selecting a different part of the form and then try adding the field again. For more information about using the Field List pane, see the article Add a field to a form or report.

  1. Use the tools in the Controls group on the Format tab to add a logo, title, page numbers, or the date and time to the form.

Access Ribbon Image

  1. If you want to add a wider variety of controls to the form, switch to Design view by right-clicking the form and then clicking Design View Button image. You can then use the tools in the Controls group on the Design tab.

Access Ribbon Image

Top of Page Top of Page

Understand controls

Controls are objects that display data, perform actions, and let you view and work with information that enhances the user interface, such as labels and images. The most commonly used control is the text box, but other controls include labels, check boxes, and subform/subreport controls.

Controls can be bound, unbound, and calculated:

  • Bound control    A control whose source of data is a field in a table or query is called a bound control. You use bound controls to display values that come from fields in your database. The values can be text, dates, numbers, Yes/No values, pictures, or graphs. For example, a text box on a form that displays an employee's last name might get this information from the Last Name field in the Employees table.
  • Unbound control    A control that doesn't have a source of data (such as a field or expression) is called an unbound control. You use unbound controls to display information, lines, rectangles, and pictures. For example, a label that displays the title of a form is an unbound control.
  • Calculated control    A control whose source of data is an expression, rather than a field, is called a calculated control. You specify the value that you want to use as the source of data in the control by defining an expression. An expression can be a combination of operators (such as = and + ), control names, field names, functions that return a single value, and constant values. For example, the following expression calculates the price of an item with a 25 percent discount by multiplying the value in the Unit Price field by a constant value (0.75).
=[Unit Price] * 0.75

An expression can use data from a field in the form's underlying table or query, or data from another control on the form.

For more information about expressions, see the links in the See Also section.

When you create a form, it is probably most efficient to add and arrange all the bound controls first, especially if they make up the majority of the controls on the form. You can then add the unbound and calculated controls that complete the design by using the tools in the Controls group on the Design tab in Design view.

You bind a control to a field by identifying the field from which the control gets its data. You can create a control that is bound to the selected field by dragging the field from the Field List pane to the form. The Field List pane displays the fields of the form's underlying table or query. To display the Field List pane, press ALT+F8, or on the Design tab, in the Tools group, click Add Existing Field. When you double-click a field in the Field List pane, Access adds the appropriate type of control for that field to the form.

Alternatively, you can bind a field to a control by typing the field name in the control itself or in the box for the Control Source value in the control's property sheet. The property sheet defines the characteristics of the control, such as its name, the source of its data, and its format. To open the property sheet, press F4.

Using the Field List pane is the best way to create a bound control for two reasons:

  • Access automatically fills in the control's attached label with the name of the field (or the caption defined for that field in the underlying table or query), so you don't have to type the control's label yourself.
  • Access automatically sets many of the control's properties to the appropriate values according to the properties of the field in the underlying table or query (such as the Format, Decimal Places, and Input Mask properties).

If you already created an unbound control and want to bind it to a field, set the value in the control's Control Source property box to the name of the field. For details about the Control Source property, press F1 while the cursor is in the property's drop-down list.

Top of Page Top of Page

Understand control layouts

Control layouts are guides that align your controls horizontally and vertically to give your form a uniform appearance. You can think of a control layout as a table, where each cell of the table contains a control. The following procedures show you how to add, remove, or rearrange controls in control layouts.

Control layouts come in two varieties: tabular and stacked.

  • In tabular control layouts, controls are arranged in rows and columns like a spreadsheet, with labels across the top. Tabular control layouts always span two sections of a form; whichever section the controls are in, the labels are in the section above.

Basic tabular control layout

  • In stacked layouts, controls are arranged vertically like you might see on a paper form, with a label to the left of each control. Stacked layouts are always contained within a single form section.

Basic stacked control layout

You can have multiple control layouts of either type on a form. For example, you might have a tabular layout to create a row of data for each record, and then one or more stacked layouts underneath, containing more data from the same record.

Create a new control layout

Access automatically creates stacked control layouts in either of the following circumstances:

  • You create a new form by clicking Form in the Forms group on the Create tab.
  • You create a new form by clicking Blank Form in the Forms group on the Create tab, and then dragging a field from the Field List pane to the form.

On an existing form, you can create a new control layout by doing the following:

  1. Select a control that you want to add to the layout.
  2. If you want to add other controls to the same layout, hold down the SHIFT key and also select those controls.
  3. Do one of the following:
    • On the Arrange tab, in the Control Layout group, click Tabular Button image or Stacked Button image.
    • Right-click the selected control or controls, point to Layout, and then click Tabular Button image or Stacked Button image.

Access creates the control layout and adds the selected controls to it.

Switch a control layout from tabular to stacked, or from stacked to tabular

To switch an entire layout from one type of layout to the other:

  • Select the control layout by clicking the orange layout selector at the top left corner of the layout. All of the cells in the layout are selected.
  • Do one of the following:
    • On the Arrange tab, in the Control Layout group, click the layout type you want (Tabular Button image or Stacked Button image ).
    • Right-click the control layout, point to Layout, and then click the layout type you want.

Access rearranges the controls into the layout type you want.

Split one control layout into two layouts

You can split a control layout into two layouts by doing the following:

  1. Hold down the SHIFT key and click the controls you want to move to the new control layout.
  2. Do one of the following:
    • On the Arrange tab, in the Control Layout group, click the layout type you want for the new layout (Tabular Button image or Stacked Button image ).
    • Right-click the selected controls, point to Layout, and then click the layout type you want for the new layout.

Access creates a new control layout and adds the selected controls to it.

Rearrange controls in a control layout

  • You can move a control within a control layout by dragging it to the location you want. As you drag the field, a horizontal or vertical bar indicates where it will be placed when you release the mouse button.
  • You can move a control from one control layout to another control layout of the same type. For example, you can drag a control from one stacked layout to another stacked layout, but not to a tabular layout.

Add controls to a control layout

To add a new field from the Field List pane to an existing control layout    

  • Drag the field from the Field List pane to the layout. A horizontal or vertical bar indicates where the field will be placed when you release the mouse button.

To add existing controls to an existing control layout    

  1. Select the first control you want to add to the control layout.
  2. If you want to add other controls to the same layout, hold down the SHIFT key and also select those controls. You can select controls in other control layouts.
  3. Do one of the following:
    • If the form is open in Design view, drag the selected fields to the layout. A horizontal or vertical bar indicates where the fields will be placed when you release the mouse button.
    • If the form is open in Layout view:
  1. On the Arrange tab, in the Control Layout group, click the type of the layout to which you are adding the controls. If you are adding controls to a tabular layout, click Tabular Button image. If you are adding controls to a stacked layout, click Stacked Button image.

Access creates a new layout and adds the selected controls to it.

  1. Drag the new layout to the existing layout. A horizontal or vertical bar indicates where the fields will be placed when you release the mouse button.

Remove controls from a control layout

Removing a control from a control layout allows you to place it anywhere on the form without affecting the positioning of any other controls.

  • Select the control you want to remove from the layout. To select multiple controls, hold down the SHIFT key and then click the controls you want to remove. To select all of the controls in the layout, click the layout selector box at the top left corner of the layout.
  • Do one of the following:
    • On the Arrange tab, in the Control Layout group, click Remove Button image.
    • Right-click one of the selected controls, point to Layout, and then click Remove Button image.

Access removes the selected controls from the layout.

Top of Page Top of Page

Understand Layout view and Design view

Layout view    Layout view is the most intuitive view to use for form modification, and it can be used for nearly all the changes you would want to make to a form in Office Access 2007. In Layout view, the form is actually running, so you can see your data much as it will appear in Form view. However, you can also make changes to the form design in this view. Because you can see the data while you are modifying the form, this is a very useful view for setting the size of controls or performing almost any other task that affects the appearance and usability of the form.

Certain tasks cannot be performed in Layout view and require switching to Design view. In certain situations, Access displays a message telling you that you must switch to Design view to make a particular change.

Design view    Design view gives you a more detailed view of the structure of your form. You can see the Header, Detail, and Footer sections for the form. The form is not actually running when it is shown in Design view, so you cannot see the underlying data while you are making design changes; however, there are certain tasks you can perform more easily in Design view than in Layout view. You can:

  • Add a wider variety of controls to your form, such as labels, images, lines, and rectangles.
  • Edit text box control sources in the text boxes themselves, without using the property sheet.
  • Resize form sections, such as the Form Header or the Detail section.
  • Change certain form properties that cannot be changed in Layout view (such as Default View or Allow Form View).

Top of Page Top of Page

Fine-tune your form in Layout view

After you create a form, you can easily fine-tune its design by working in Layout view. Using the actual form data as your guide, you can rearrange the controls and adjust their sizes. You can place new controls on the form and set the properties for the form and its controls.

To switch to Layout view, right-click the form name in the Navigation Pane and then click Layout View Button image.

Access shows the form in Layout view.

You can use the property sheet to modify the properties for the form and its controls and sections. To display the property sheet, press F4.

You can use the Field List pane to add fields from the underlying table or query to your form design. To display the Field List pane, do one of the following:

  • On the Format tab, in the Controls group, click Add Existing Fields Button image.
  • Press ALT+F8.

You can then drag fields directly from the Field List pane onto your form.

  • To add a single field, double-click it or drag it from the Field List pane to the section on the form where you want it displayed.
  • To add several fields at once, hold down CTRL and click the fields that you want to add. Then drag the selected fields onto the form.

Top of Page Top of Page

Fine-tune your form in Design view

You can also fine-tune your form's design by working in Design view. You can add new controls and fields to the form by adding them to the design grid. The property sheet gives you access to a large number of properties that you can set to customize your form.

To switch to Design view, right-click the form name in the Navigation Pane and then click Design View Button image.

Access shows the form in Design view.

You can use the property sheet to modify the properties for the form and its controls and sections. To display the property sheet, press F4.

You can use the Field List pane to add fields from the underlying table or query to your form design. To display the Field List pane, do one of the following:

  • On the Format tab, in the Controls group, click Add Existing Fields Button image.
  • Press ALT+F8.

You can then drag fields directly from the Field List pane onto your form.

  • To add a single field, double-click it or drag it from the Field List pane to the section on the form where you want it displayed.
  • To add several fields at once, hold down CTRL and click the fields that you want to add. Then drag the selected fields onto the form.
  • To add a single field, double-click it or drag it from the Field List pane to the section on the form where you want it displayed.
  • To add several fields at once, hold down CTRL and click the fields that you want to add. Then drag the selected fields onto the form.

Top of Page Top of Page

Add controls to your form

Some controls are created automatically, such as the bound control that is created when you add a field from the Field List pane to your form. Many other controls can be created in Design view by using the tools in the Controls group on the Design tab.

Access Ribbon Image

 Note   Many of the tools in the Controls group are accessible only while your form is open in Design view. To switch to Design view, right-click the form name in the Navigation Pane and then click Design View Button image.

Determine the name of a tool

  • Place the mouse pointer over the tool.

Access displays the name of the tool.

Use Control Wizards

You can use wizards to help you create command buttons, list boxes, subforms, combo boxes, and option groups. On the Design tab, in the Controls group, if Use Control Wizards is not selected, click it to select it.

Use Control Wizards button

If you prefer to create controls without the help of the wizard, click Use Control Wizards so that it is not selected.

Use Control Wizards button

Create a control by using the tools in the Controls group

  1. Click the tool for the type of control that you want to add. For example, to create a check box, click the Check Box tool.
  2. Click in the form design grid where you want to position the upper-left corner of the control. Click once to create a default-sized control, or click the tool and then drag the mouse pointer in the form design grid to create a control of the size that you want.
  3. If you selected Use Control Wizards and the control that you are placing has a wizard associated with it, the wizard starts and guides you through the settings for the control.
  4. If you don't position the control perfectly on the first try, you can move it by doing the following:
  • Click the control to select it.
  • Position the mouse pointer over the control until the pointer turns into a four-headed arrow Move pointer.
  • Click and drag the control to the location that you want.

If you use a Control Wizard, the wizard might contain steps to help you bind the control to a field. Otherwise, this procedure creates an unbound control. If the control is of the type that can display data (a text box or check box, for example), you must enter a field name or expression in the Control Source property box for the control before it will display any data. To display the properties for a control, select the control and then press F4. For more information, see the Understand controls section.

Top of Page Top of Page

Save your work

After you save your form design, you can run the form as often as you want. The design stays the same, but you see current data every time you view the form. If your needs change, you can modify the form design or create a new form that is based on the original.

Save your form design

  1. Click the Microsoft Office Button Button image, and then click Save, or press CTRL+S Button image.

Alternatively, click Save Button image on the Quick Access Toolbar, or press CTRL+S.

  1. If the form is untitled, type a name in the Form Name box, and then click OK.

Save your form design under a new name

  1. Click the Microsoft Office Button Button image, and then click Save As Button image.
  1. In the Save As dialog box, type a name in the Save Form To box, select Form in the As list, and then click OK.

Top of Page Top of Page

 
 
Applies to:
Access 2007