Table of Contents
Access forms are interfaces that connect the user with data stored in tables and queries. Database developers design and structure forms so that users can enter, review, and print data from tables and queries most effectively. When a form is bound to a particular table or query, users navigate through the form to view records from this table or query one at a time. This is a welcome alternative to requiring users to hunt for specific records in large unwieldy tables or to manually enter data line-by-line into these tables. Forms can also be designed to simplify user movement around a database application, i.e. from form to form or form to report. With Access, developers control the appearance of forms by combining text, pictures, drop-down lists, lines, boxes, and color to create an attractive and fully interactive on-screen environment. As a result, forms make the tasks of data retrieval and entry much more intuitive.
A form does not store the data it presents. It keeps only your design parameters, such as what controls go where, what colors and graphics to use, section sizes, etc. A form retrieves the data from the underlying table or query to which it is bound, and these data are displayed through the controls on the form. A form can be based on only one table or query but it can retrieve information from more than one table or query through the use of subforms or by setting a table or query as the control source for particular controls.
There are various ways you can view a form. When you create or edit a form's layout or content, you work in the form's Design View. In addition to Design View, four other views are available: Form View, Datasheet View, Pivot Table View, and Pivot Chart View. You can switch between the different views by selecting one of the view icons on the toolbar. These same choices appear in the View menu menu as well.
-
Form View: This view, shown below, is what the user sees when using Access. Form View allows you access the underlying table or query one record at a time.
Notice the arrows on the bottom left portion of the form. The user clicks on these arrows to move from one record to another.
-
Datasheet View: This view allows you to view a form in table format. In Datasheet View, you can enter and edit information as well as view several records at once. The Datasheet View is limited by screen width and its inability to display pictures, OLE objects, and command buttons (all these are visible in Form View).
-
Pivot Table View and Pivot Chart View: These views allow you to create interactive tabular or graphical displays of your data. In these views, the developer places fields on either axis and develops a table or graph that organizes information differently than how it appears both in the form and in the underlying table or query. Once you create a Pivot Table view or a Pivot Chart view, the particular view gets saved with your form. (See "About Designing a PivotTable or PivotChart View" in Microsoft Access Help for information on how to create these views.)
-
Design View: This view is what you use when creating and changing forms. Below is an example of the above form in Design View, complete with Toolbox, Properties window, and Field List, which are tools that are available Design View:
From Design View, you can perform the following tasks:
-
Bind the form to an underlying table or query by using the Properties window.
-
Change form, control, and section properties in the Properties Window.
-
Access fields from the underlying table or query through the Field List.
-
Access your Toolbox, which contains all available controls.
-
Place controls anywhere on the form.
-
Align your controls using rulers at the top and left edges of the form window.
-
Bind controls to fields in tables or queries.
-
Move and resize controls on the form.
-
View the form split up into sections.
-
View the form in a grid format.
You cannot, however, scroll through or otherwise view records from Design View. As a result, it is common for developers to switch from Design View to Form View and back during the design precess in order to see what the form looks like (you can do this with the other views as well).
-
You create a new form by selecting Forms in the left sidebar of the Database Window and then clicking New. At this point, you can choose between using the Form Wizards or working from a blank form.
One advantage of wizards is that they perform many basic formatting tasks and allow you to concentrate on refining special features of the form. There are four basic types of wizards:
-
Form Wizard: This is the most flexible wizard.
It will ask you to select a table or query that your form will be based on. Once a table or query is selected, all the fields from that table or query appear beneath Available Fields. You can individually select each field that you want by clicking on it and pressing the right arrow button. You can also select all the fields in the table or query by pressing the double right arrow button. The fields that you selected appear beneath Selected Fields. You can unselect any or all selected fields by pressing either of the left arrow buttons.
After pressing Next, the Form Wizard will prompt you to choose the layout and style you think will work best. Thus, from the following query, taken from the Northwind database that comes with your Access Application...
...the Form Wizard produces the following form:
Notice that the form comes with navigation buttons that will allow the user to view each record one-by-one or to go immediately to the beginning or end of the list.
The Form Wizard also allows you to work with fields stored in multiple tables or queries to create a main form and what is called a subform, which is basically a form inserted in another form. Often, the table that underlies the main form is related to the table that underlies the subform. The main form often represents the "one" side of the relationship, and the subform, the "many" side. See [ http://help.unc.edu/?id=1898 ] Access XP/2000 Tables for more information on tables and relationships and "Subforms" below for more information on subforms.
Note that you can also use the Form Wizard by selecting Create form by using wizard in the Access window.
-
AutoForms: Auto Forms do not allow the same kind of decision making as the Form Wizard, but they are the quickest and easiest way to create forms. These forms automatically display every field in the underlying table in either a datasheet, columnar, or tabular display. You must first select a table or query on which to base the form before using the AutoForms. The AutoForms are as follows:
-
AutoForm: Columnar displays the values in one column with each field on a separate line.
-
AutoForm: Tabular displays several records at the same time in rows and columns.
-
AutoForm: Datasheet displays the values from the underlying table/query in datasheet view.
-
AutoForm: Pivot Table creates an interactive table that allows you to organize, summarize, perform calculations on, and format large amounts of data in many different ways.
-
AutoForm: PivotChart allows you to create a graphical representation of the data.
-
-
Chart Wizard: This form displays the selected data as a graph. Just as with the Form Wizard, the Chart Wizard allows you to select the fields you wish to be represented and gives you control over how the data is organized. It also gives you a choice of twenty graphs, including bar charts, pie charts, and 3D graphs.
-
Pivot Table Wizard: Just as with the Pivot Table AutoForm, this wizard creates an interactive table that allows you to organize, summarize, perform calculations on, and format large amounts of data in many different ways. This wizard also allows you to select the fields you wish to be represented.
Click the Forms tab in the Access Window, and then select Create form in Design view, or select Design View in the New Form window. What appears is a blank form in Design View upon which controls will be placed.
The Toolbox is a special kind of toolbar that appears only in Design View and contains buttons that allow you to select the type of control or tool that best suits your needs. When you need to create controls or access tools, the Toolbox gives you quick access.
If the Toolbox is not visible in Design View, you can activate it by selecting Toolbox from the View menu, or by selecting the Toolbox icon on the toolbar:
You can deactivate the Toolbox the same way. The Toolbox is shown below:
The creation of a control using the Toolbox is as simple as clicking on a control icon on the Toolbox, and then clicking and dragging on the form to determine the position and size of the control.
Since controls are introduced in the ITS site [ http://help.unc.edu/?id=212 ] Microsoft Access XP/2000 Users: Controls , we will briefly review the controls that are most useful for forms. There are three basic types of controls: "bound," "unbound," and "calculated." Bound controls are those whose source of data is a field in a table or query in your database. A text box is the most common type of bound control. As the user navigates through the records on which a form is based, bound controls will display the values in the fields of each record. An unbound control does not have a data source in your database. Unbound controls include labels, lines, rectangles, and pictures and contain values that the database developer provides. These values do not change as the user navigates through the records. A calculated control is based indirectly on an underlying table or query in that its data source is an expression that is performed on the underlying data. This expression is usually written in the control itself. An example of a calculated control would be an arithmetic operation carried out on a given field or fields, such as:
=[Num_FT_Students] + [Num_PT_Students]
In this case, the values in two fields in an underlying table or query, Num_FT_Students (which tallies the number of full time students) and Num_PT_Students (which tallies the number of part time students), are added in the calculated control.
The controls most often used in Access are:
-
Labels: These controls contain text entered by the database developer. Labels are most often used to enhance the appearance of a form and are never bound to an underlying table or query.
-
Text boxes: These controls are boxes that contain text. They are most often bound to an underlying table or query. Users can also enter data into text boxes that appear in forms.
-
Yes/No Controls: These controls are either check boxes, option buttons, or toggle buttons. These display boolean, or yes/no, values. A check box indicating a "yes" value is a check in a small box; for an option button, it is a dot in a small circle; for a toggle button, it is a pressed button. These controls may be bound to yes/no fields in an underlying table or query. Since users more often interact with these controls, developers often assign expressions or macros to the event properties of yes/no controls.
See "About Setting the Value of a Control or Property in Response to an Event," "Set the Value of a Property in Response to an Event," and "Example of Setting the Value of a Property in Response to an Event" in Microsoft Access Help for more information on events and event properties. Also, see "About Macros and Macro Groups" and "Modify Macros" in Microsoft Access Help to learn more about macros in Access.
-
Line, Box, and Image Controls: These controls enhance the appearance of the form. Line and box controls allow the developer to partition information on the form. Image controls allow the developer to place graphics on the form.
-
Drop Down Controls: These controls are list boxes and combo boxes and both can be bound. Both are similar to text boxes except that they can can contain a list of entries, not just one. List boxes present the entire list, often with scrollbars when the list is longer than the listbox itself. Combo boxes present only one list item at a time but offer an arrow that presents the entire list when clicked.
For more information on sizing, moving, aligning, or assigning properties to controls, go to the ITS site [ http://help.unc.edu/?id=212 ] Microsoft Access XP/2000 Users: Controls.
After creating a control, you can manipulate its properties through the Properties window. To access the Properties window, select Properties from the View menu item on the toolbar, or select the Properties icon also on the toolbar:
The Properties window contains all information about the form, its sections and its controls. The Properties window also contains the name, event properties, and data source properties for each control on the form. In Access, control properties determine the appearance of the control as well as the characteristics of the data it contains. For instance, you could set control's Format and FontWeight properties in order for the control to display currency values in bold type.
Above is an example of the Properties window. Notice that the tab All is selected. This means that all the object's properties (whether it is a control, section, or form) are listed in the Properties window. The other tabs organize by function: Format contains all the object's formatting properties (such as height, width, color, font characteristics, and whether the object can shrink and grow with the data). Data includes the object's data source properties, such as the underlying field, table, or query, whether the object is enabled or locked, and whether there is validation for data entry. Event includes properties that specify an expression, macro, or module to be executed whenever an event occurs. Examples of events are OnClick, DblClick, and OnKeyDown and occur whenever the user interacts with the form. Finally, the Other tabe contains miscellaneous properties, such as Name.
Note: changing a property setting for a control or form does not affect the data or how they are presented in the underlying table or query.
Note: You select a property by clicking on that option in the Property window. If you click on the property and an arrow appears, you can click the arrow to display a list of settings. Otherwise, you can type an entry in the box.
You can use the Properties window to connect an entire form to an underlying table or query. Select the entire form by clicking the gray area beyond the form within the form window or by pressing the button at the upper left hand corner of the form:
In the Properties window, click the text area next to Record Source. A down arrow appears on the right. Click that and a list of all the tables and queries in the database appears. Select one and this will be the table or query that the controls on the form will be based on. In fact, after you select the entire form, you can manipulate all of the form's propertites through the Properties window as if the form were a control. Such properties determine the form's size, name, caption, and appearance.
One important form property is the Default View property. Default View controls the way a form looks when it is first opened. Default View has three values:
-
Single Form specifies a display of one record at a time on the screen and is useful for intense data entry.
-
Continuous Forms lets you see several records on-screen at once and is useful for displaying as many records as you want and can.
-
Datasheet displays the data in a rows and columns. Datasheets are usually used to display the "many" part of a one-to-many relationship.
Another important property is the Navigation Buttons property. If the value of this property is "Yes" then the form appears with ready-made buttons at the bottom that allow the user to proceed forward or backward through the underlying table or query. The feature also indicates which record the form is presently displaying.
The most common way to create a new control in a form is by selecting the type of control you want in the Toolbox, and then clicking in the form (or dragging the cursor to the form) to create an unbound version of that control. You can then bind the control to a field in the underlying table or query by filling in the Control Source property with the appropriate field name. You can, however, combine these two actions by using the Field List. When a form is bound to a particular table or query, a Field List appears that lists all the fields of the underlying table or query. To make this list disappear, select the following Field List icon on the toolbar:
To make it appear again, click the same icon or select Field List under the View menu item on the toolbar. When both the Field List and the Toolbox are displayed, you can click on the control type that you want in the Toolbox and then drag the field you want from the Field List to the form's design grid. The default control is the text box, which means that if you drag a field onto the form or report without first selecting a control, a text box displaying records of the chosen field will appear. If you select an inappropriate control (e.g. the Line control) a text box will also appear. In most cases, the alternatives to text boxes are list and combo boxes.
Understanding the structure of a form is very important when you design forms. Access forms use three nested sections, which you can manipulate in Design View (shown above). The three basic sections of a form are:
-
Form Headers and Footers: These sections appear at the top and bottom of every page when the form is displayed in Form View. When a form is printed, the Form Header appears at the top of the first page, and the Form Footer appears at the bottom of the last page. You can prevent a section's Form Header or Footer from being printed by setting the DisplayWhen property to Screen Only. Often, Form Headers and Footers contain labels that describe the entire form.
-
Page Headers and Footers: These sections display information such as a title, column totals, or column headings at the top or bottom of every page. Page Headers and Footers can be manipulated in Design view, but appear only on printed forms, not in Form view.
-
Details: This section displays data from either one record or as many records as will fit at once on the screen. There is at least one Detail section for each record in the underlying table or query of a form. The majority of your controls should be placed in Details.
The Details section is always nested between the Page Headers and Footers, and the Page Headers and Footers are always nested between the form headers and footers. You can create or delete Page Headers and Footers as well as Form Headers and Footers in Design view by right-clicking the screen and checking (or unchecking) the appropriate items in the menu that appears. You can also check (or uncheck) Form Header/Footer or Page Header/Footer in the View menu.
To change the size of sections, place the mouse pointer on the bottom or right edge of the section you want to adjust. The pointer will change from the standard white arrow to a black, multi-pointed arrow when you are on the edge. Then, drag the edge until the section is the size you want. You can use the rulers at the top and left of the form to size the sections exactly. You can change the height of sections independently, but a form has only one width. When you change the width of a section, you change the width of the entire form.
Sections also have their own properties. To view or manipulate the properties of a particular section, select the section by clicking the horizontal bar above the section. The bar will turn black to indicate that it is selected. The Properties window will display the section's properties.
All sections have three properties in common: Height, Back Color, and Special Effect. These are all found under the Format tab. Height determines the height of each section in pixels. Back Color determines the color of the section, and Special Effect determines the whether the section will appear raised, sunken, or flat on the form.
The ForceNewPage property, under the Format tab applies only to Form header sections, Form footer sections, and Details sections the form is printed. It specifies whether form each section prints on a separate page, rather than on the current page with the previous section.
Developers insert forms within forms in order to include information from more than one table in a form. Access calls the primary form the main form and the form within the form the subform. In the sample form below, the main form displays information about an author from a table called "Authors," and the subform, which is linked to a table called "Novels," displays novels written by that author.
In many cases, the underlying table behind the subform is related to the underlying table behind the main form. In the example above, the two underlying tables, "Authors" and "Novels," are linked by the field Author_ID, which appears in both tables. While Author_ID is a unique field in "Authors" (each author can only have one Author_ID number), it is not unique in Novels (more than one novel can have the same Author_ID number since authors often write more than one novel). Every time the user navigates through the main form (i.e. proceeds to another author and author_ID number in the underlying table), a new subform appears displaying all of the new author's novels that are listed in the database. In this instance, navigating through the main form will change the subform, and not the other way around.
The relationship between the two underlying tables, "Authors" and "Novels," is called a one-to-many relationship. Understanding the kinds of relationships that can exist between tables is crucial for understanding the use and behavior of subforms. For more information on relationships among tables see the ITS help document [ http://help.unc.edu/?id=1898 ] Microsoft Access XP/2000: Tables.
The easiest way to create a form/subform is to press the Subform icon (below) on the Toolbox when in Design view and then click on the form.
This initiates the Subform Wizard, which is very similar to the Form Wizard. By simply following the instructions in the series of dialog boxes presented by the wizard, you can select the table on which you wish to base the subform and the fields you wish to appear in the subform. When the wizard is completed, a link to the subform appears in the database window under Forms alongside links for the other forms.
You can also manually add a subform to a main form. To do this, follow the steps below:
-
Create the main form as would normally.
-
Create the form that you intend to be the subform. This form can be created like any other form.
-
Open the main form in Design View.
-
Switch to the Database Window ( press <F11> ).
-
Select the form that you intend to be the subform and drag it from the Database Window to the desired place on the main form.
-
Move the subform control and adjust its size to your tastes.
-
Switch to Form View to see the results.
There are two ways to select a subform while it is being displayed in a main form in Design View: as a control or as a separate form.
To select a subform as a control in the main form, click on the outer borders of the subform. The properties window appears with properties that relate to the subform's status as a control. Examples are the LinkChildFields and LinkChildFields properties under the Data. These properties deal with how the main form and the subform are related and will be discussed below.
To select a subform as a form, first select the subform as a control and then click on the upper left hand corner of the subform (shown above). This allows you to select the subform as you would any other form. The properties that appear in the Properties window relate to the subform's status as a form, and will be the same as any form.
You will note that the default appearance of a subform is in tabular, or datasheet, mode. You can change this by selecting and altering the properties of a subform either while it's displayed in the main form (by selecting it as a form, not a control) or by opening the subform from the database window itself as you would any other form. In either case, you open the subform's Properties window and set the DefaultView property under the Format tab to "Single Form."
Access recognizes when a form and subform are based on related tables and automatically links the subform to the form when you create the subform. But this can only happen if:
-
The main form and the subform are based on tables (not queries) that have an established relationship.
-
The main form is based on a table with a primary or unique key (field).
-
The subform contains a field with the same name as that primary key and must have the same or a compatible data type.
You can place a subform in a main form when these forms are based on unrelated tables. What results is a subform that does not change as the user navigates through the main form. You can, however, manually link unrelated tables that underly a main form and a subform by doing the following:
-
Open the main form in design view.
-
Select the subform as a control and open its properties window.
-
Press the Data tab.
-
Set the LinkChildFields property to the name of the linking field in the table underlying the subform.
-
Set the LinkMasterFields property to the name of the linking field in the table underlying the main form.
This option also appears in the Subform Wizard whenever underlying tables do not already have a relationship. In either case, however, the linking fields must be of compatible data types for this to succeed.
A Switchboard is a form that provides an entry way into your database. It is often the first thing the user sees upon opening your database and it can either announce the name and puropse of the database or it can provide easy ways for the user to open your database objects such as forms and reports. The user does this through an Access control called a command button, shown below.
Switchboards often have many command buttons, which are the main way users interact with switchboards. When the user "presses" a command button by clicking on it, Access is programmed to respond in certain ways.
To create a switchboard follow the steps below:
-
Go to Tools menu on your database menu.
-
Select Database Utilities. You will then see a list of features that you can use.
-
Select Switchboard Manager. If you do not already have a switchboard created, access will prompt you to make one. The Switchboard Manager then appears.
-
Press New in the Switchboard Manager
-
In the Create New dialog box which appears, enter the name of the new switchboard, and click OK. Access adds the switchboard to the Switchboard Pages box in the Switchboard Manager.
-
In order to add features to this new switchboard, select the new switchboard in the Switchboard Pages list box in the Switchboard Manager, and click Edit.
-
Click New in the Edit Switchboard Page dialog box which appears.
-
Type the words that will appear on the first switchboard command button in the text box marked Text and then select a command from the Command combo box. For example, type "Open Authors Form" in the text box marked Text and then select Open Form In Edit Mode in the Command box. After this, you select the form you wish to open (in this case, "Authors") in the combo box at the bottom of the dialog box labeled Forms . This will place a button on your switchboard that, when pressed, will open a form in your database called "Authors". Also, to create a switchboard that opens other switchboards, select the Go To Switchboard command in the Command box, and then specify the switchboard you want to go to in the combo box below. You can also specify other commands: Run Macro, Exit Application, Open Form in Edit mode, etc.
-
Repeat these steps until you've added all the buttons you need for your switchboard.
To edit or delete a command button on a switchboard, click the switchboard in the Items On This Switchboard box in the Switchboard Manager and click Edit or Delete. If you want to rearrange buttons on your switchboard, select the button in the list box in the Switchboard Manager, and click Move Up or Move Down. You can also specify which switchboard will be your default switchboard by selecting a switchboard in the Switchboard Manager and pressing Make Default.
When you create a switchboard, Access creates a table called Switchboard Items that describes what the command buttons on the switchboard display and do. Upon finishing creating the switchboard, click Close. You can then open the switchboard in Design View in tweak its appearance if you choose.
To have Access launch your default switchboard (or any other form) when the user opens the database, go to Tools, StartUp, and select your switchboard from the Display Form/Page combo box.



I have created a form that fetches data from more than one tables. All the related tables have the same primary key (employee number) and they cover different aspects of employees i.e. basic data, address, career record, health record etc. The problem is that the form does not show the existing records once opened. It can add new data to all the tables however. Just for experimentation, I created separate forms for all the tables and they show the existing data and perform other functions on tables. Why don't I see the existing data in the main form that I created initially using a form wizard. Please guide me as I have seen enough of help on it but to no avail. I have checked that there is no filter, I have checked that "Data Entry" property is set to "No" etc. Grateful.