Home

The Characteristics of a Form

 

Anatomy of a Form
 

The Object's Tab

Remember that, when displaying data to a user, the form shows in Form View, if you are designing, or modifying the design of, a form, you must display it in Design View. In some case, whether in Form View or in Design View, a form is represented by a tab that displays an icon Form Icon.

Practical Learning: Introducing Forms and Reports' Properties

  1. Start Microsoft Access and open the Hotel Management1 database you started in the previous lesson
  2. To create a new form, on the ribbon, click Create and, in the Forms section, click Blank Form
  3. To save the new form, right-click the Form1 tab and click Save
  4. Set the name to Central and press Enter
  5. To switch the form to Design View, on the right side of the status bar, click the Design View button Design View
  6. To access the properties of the form, double-click the button at the intersection of the rulers
 
 

The Caption of a Form

On the right side of its icon Form Icon, by default, a form displays its name. In reality, the string on the right side of the icon is called the caption of the form. The caption of a form is recognized by the Caption property. If you do not specify the caption, the title bar of a form displays its name.

To specify the caption of a form, access its Properties window and, in the Format or the All tab, click Caption and type the desired string.

Practical Learning: Specifying the Caption of a Form

  1. In the Properties window of the form, click the Format tab and click Caption
  2. Type Main Switchboard and press Enter
  3. To save the form, press Ctrl + S

Tabbed Documents or Overlapped Windows?

We mentioned that a form was represented in its top section by a tab. When a form displays with a tab, the right section of the tab(s) displays a close button Close that you can use to close the form.

If you want, you can replace the tab of a form and let the form display without the tab. To do this, click the Office Button and click Access Options. In the left frame of the Access Options dialog box, click Current Database. In the right frame and in the Document Window Options section, click the Tabbed Documents radio button and remove the check mark on the Display Document Tabs check box, then click OK. On the message box that appears, click OK. Close and reopen the database. By default, a form displays with a tab, in which case the user cannot move it. Otherwise, a form can appear as a regular window with its system buttons. To take care of this, you can click the Office Button and click Access Options. In the left frame, you can click Current Database and, in the right frame, in the Document Window Options sections, click the Overlapping Windows radio button:

After making the selection, you can click OK. You will be asked to close and reopen the database:

Which you should do.

The Control Box

If you display a form as overlapped, it would be equipped with three system buttons , or . Here is an example:

The group of these buttons is called the Control Box. If you do not want these system buttons at all, access the Properties window of the form and set the Control Box Boolean property to No from its Yes default value. In this case, the form would appear with neither the system icon nor the system buttons. If you do this, make sure the user has a way to close the form.

The Min/Max Buttons

Instead of completely hiding all system buttons of a form, you can specify which ones to display and thus control the ability to close, minimize, or maximize the form. The presence and/or the role of the system buttons is (partly) managed by the Control Box and the Min Max Buttons properties. When the Control Box property is set to No, regardless of the value of the Min Max Buttons property, there would be no system buttons on the title bar. If you want to control the appearance and behavior of the system buttons, the Control Box property must be set to Yes. The values of the Min Max Buttons produce the following results:

Min Max Buttons Result System Buttons Consequence
Minimize Maximize Close
None Hidden Hidden Available The form can only be closed
Min Enabled Enabled Disabled Available The form can be minimized or closed but not maximized
Max Enabled Disabled Enabled Available The form cannot be minimized but can be maximized
Both Enabled Enabled Enabled Available All operations (minimize, maximize, restore, and close) are allowed

Depending on the role and probably the number of Windows controls on a form, you will decide what button to allow or not.

Practical Learning: Accessing the System Buttons of a Form

  1. Click the Office Button and click Access Options
  2. In the left frame, click Current Database
  3. In the right frame, in the Document Window Options, click the Overlapping Windows radio button
  4. Click OK
  5. On the Microsoft Office Access message box, click OK
  6. Close Microsoft Access
  7. Restart Microsoft Access and re-open the Hotel Management1 database
  8. To reopen the Central form, in the Navigation Pane, right-click Central and click Design View

The Form’s Borders

Whether you allow the system icon and system buttons or not, the user needs to be able to know where a form starts and where it ends. This is seen by the borders of the form. In most cases, you will not be concerned with this aspect. Otherwise, you can control the borders of a form.

The borders of a form are controlled using the Border Style property. If you set it to None, the form would appear without borders.

Form Layout

The main area of the form is what the user will mostly use. This is also referred to as the body of the form. If you create a form using the Form Wizard, it (the wizard) can assist you with deciding how the objects in the body of the form would display. Forms can be designed in various flavors: Columnar, Datasheet, Tabular, Justified

When using the split form, if you click a record in the bottom section, its values display in the top section.

To automatically generate a split form, in the Navigation Pane, click the table that holds the records. Then, on the Ribbon, click Create. In the Forms section, click Split Form.
To create a split form by design, start a form in Design View or display an existing form in Design View. In the Properties window of the form, set its Record Source to the table that holds the value and set its Default Value to Split Form. If it is bran new form without some previously created fields, use the Field List to add the desired fields to it.

The Sections of a Form

 

The Detail Section

When it comes up, a form is presented as a rectangular box. A form in Design View is made of a form selection button, two rulers, two scroll bars, a horizontal bar labeled Detail, and a body. By default, a form presents a section referred to as the Detail section. This section starts from the Detail bar to the lower end of the section. The Detail bar displays only when the form is in Design View.

The Form Header and the Form Footer

Besides the Detail section, a form can be equipped with a section on top and another section in its bottom part. To add these sections, you can:

Any of these two actions would add two new sections to the form: the Form Header section on top and the Form Footer section at the bottom:

Although two sections are added, you can reduce one completely so it would not appear to the user. This means that you can keep one section and hide the other. If you create a form using the Form Wizard, both the header and the footer sections are added but the footer section is completely reduced so it would not appear to the user. If you want to display it to the user, you must expand it.

Practical Learning: Creating the Sections of a Form

  1. While the form is still displaying in Design View, on the ribbon, click Arrange if necessary.
    In the Show/Hide section, click the Form Header/Footer button Form Header/Footer
  2. Save the form

The Page Header and the Page Footer

A form can also be equipped with two other sections. To get them, you can:

Any of these actions would add two new sections to the form: a Page Header and a Form Header sections. These sections would not appear to the user. They appear only if the user decides to print a form, in which case they would appear on the printed paper. Like the form sections, you can use either one or both the Page Header and the Page Footer sections

Dividing Lines

A form is equipped with special horizontal lines used to visually separate sections of a form. They do not perform any other special action. To equip a form with dividing lines, add a header and a footer sections. If you create a form that is directly equipped with a header and a footer sections, it would display the dividing lines.

The presence or absence of the horizontal lines is controlled by the Boolean Dividing Lines property. If you set its value to Yes, the dividing horizontal lines would display on the form. To hide both lines, you can set this properties value to No. To hide an individual line, you can completely reduce its section.

Practical Learning: Using Dividing Lines

  1. On the form, double-click the button at the intersection of the rulers.
    In the Properties window, click the Format tab and set the Dividing Lines field to Yes
  2. Save the form

The Records of a Form

 

The Form's Scroll Bars

As much as you can, you should design your (non-Datasheet) form to display all of the fields of a record whenever the/a record comes up. Sometimes this will not be possible. If a form possesses too many fields for each record, Microsoft Access would equip the form with one or two scroll bars. A scroll bar allows the user to scroll from one side of the form to another. The vertical scroll bar is used to scroll up and down while the horizontal scroll bar allows scrolling left and right:

By default, scroll bars come up if the form "judges" them necessary, such as if some fields, or some area of some fields, are hidden. The presence of scroll bars allows the user to be aware of hidden fields. Depending on your design, you can control the appearance or disappearance of the scroll bars. To do this, change the values of the Scroll Bars field in the Format property page. There are four possible values. To display only the vertical scroll bar, set the value to Vertical Only:

In the same way, you can display only the horizontal scroll bar by selecting Horizontal Only. On the other hand, you can display both scroll bars by setting the value to Both. If for some reason you do not want any scroll bar, set the Scroll Bars property value to Neither.

The Record Selectors

A form is equipped with a special area that allows you to select a record. This area is called the Record Selector. The Record Selector is on the left side immediate to the left side of a record on the form. Its size depends on the type of record. For a regular form (Single Form), the record selector is the long vertical box on the left of all records:

Record Selector

On a datasheet form, a tabular form, or the datasheet section of a split form, the record selector is the box on the left side of each individual record. This means that the view of the form can display many record selectors, one for each record. In the following screenshot, the record selector of each record is the blue box on its left:

If you do not want a form to display the record selector(s), in its Design View, set its Record Selectors property to No.

Practical Learning: Hiding the Control Selectors

  1. In the Properties window, click the Format tab and double-click Record Selectors to set its value to No
  2. Save the form
  3. To preview the form, on the right side of the status bar, click the Form View button
  4. To return to Design View, right-click the title bar of the Central form and click Design View

Navigation Buttons

In the bottom section, a form is equipped with the same navigation buttons used on tables. These buttons are useful only if the form is meant to display data. The buttons are available if the form is displayed in a view other than the Design View.

If you do not want a form to display the navigation buttons, set its Navigation Buttons property to No.

Practical Learning: Configuring the Navigation Buttons

  1. In the Format tab of the Properties window, double-click Navigation Buttons to set its value to No
  2. To preview the form, right-click the Central tab and click the Form View button
  3. To return to Design View, on the right side of the status bar Form View
  4. Save the form

Navigation Caption

By default, a form is equipped with a status bar or navigation bar. On the left side of the bar, it displays the Record: label. If you want, you can change that string to a short one of your choice. To change the text on the left side of the navigation bar, in the Properties window of the form, click the Format tab and, in the Navigation Caption field, enter a string of your choice. Here is an example of a result (notice the Navigation string on the lower-left side of the bottom bar):

The Size of a Form

 

The Width of a Form

The width of a form is the distance from its left border to its right border. The width of a form is the common width of each one of its sections. All sections use the same width. To widen or narrow a form, position the mouse on the right border of one of its sections. The mouse cursor would turn into a vertical line with a horizontal double arrow:

You can then click and drag right to widen or left to narrow the form.

The width of a form is a numeric value. To change its value with more precision, access the Properties window of the form. In either the Format or the All tab, click the Width field, type a decimal value and press Enter.

Practical Learning: Changing the Width of a Form

  1. Double-click the button at the intersection of the rulers.
    In the Format tab of the Properties window, click Width
  2. Type 4.5 and press Enter

The Height of a Form

The height of a form is controlled by its sections. For this reason, each section controls its own height. The total heights of all sections constitute the height of the form. Based on this, to resize a form, you must actually resize one or some of its sections. To heighten a section on a form, position the mouse on the lower portion of the section. For the headers or the Detail sections, that will be the upper border of the lower bar. For the lowest section, the mouse must be positioned on the lower border. The cursor turns into a narrow horizontal line with a vertical double-arrow:

The height is a numeric value. As mentioned already, each section of a form controls its own height. Based on this, to numerically change the height of a section of a form, access the Properties window of that section. In either the Format or the All tab, click the Height field, type a decimal value and press Enter. This also means that, to set the total height of a form, you can change the Height value of each section.

Practical Learning: Changing the Height of a Form

  1. On the form, double-click the Form Header bar
  2. In the Format tab of the Properties window, click Height and type .5
  3. On the form, click the Detail bar
  4. In the Format tab of the Properties window, click Height and type 2.5
  5. On the form, click the Form Footer bar
  6. In the Format tab of the Properties window, click Height and type .35 and press Enter
  7. Save the form

Both the Width and Height of a Form

To change both the width and the height of a form at the same time, you can position the mouse on the lower-right corner. The cursor would change into a small square with 4 arrows:

You can then click and drag left, right, up, down, or diagonally.

To numerically change the width and the height of a form, change the value of the Width of the form. Then change the Height values of the individual sections.

Automatically Centering a Form

When you open a form from the Navigation Pane, the object is positioned from the top-left corner of the gray area of Microsoft Access. If you want the form to be automatically centered, access its Properties window and, in the Format or the All tab, set its Auto Center Boolean property to Yes from its default No value.

Fitting the Screen

While designing a form, you may stretch its right and/or its bottom borders beyond the actual borders of the form. Consider the following screenshot:

When you preview the form, it would appear with the expanded size, which is not the actual size of the form. The above form would produce:

When the form is previewed, to get its actual size, on the ribbon, click Home. In the Window section, click the Size To Fit Form Size to Fit Form.

The Background Picture of a Form

 

Introduction

Except when we used the Form Wizard, all of the forms we had created so far had a white background. If you want, you can cover a form with a picture. Microsoft Access provides a few pictures but you can also use a picture of your own.

To use a picture as a background, after accessing the properties of the form, in the Format or the All tab, you can click Picture and click its browse button. This would open the Insert Picture dialog box that allows you to locate and select a picture. Microsoft Access supports all the popular picture formats, including BMP, JPEG, GIF, and PNG. After selecting the picture, you can click OK.

Because the Picture property (unfortunately) belongs to the form and not to one of its sections, the picture you use would cover all sections of the form.

Obviously before using a picture, you should design or be very familiar with it. This is because you may want one sample of the picture to cover the whole form. Here is an example:

This would produce:

Practical Learning: Setting the Background of a Form

  1. From the resources that accompany our lessons, open the Danilo Pizza1 database
  2. In the Navigation Pane, under Pizza Orders: Table, double-click (the) Pizza Orders (form) to open it
  3. After viewing the form, to change its view, right-click its tab and click Design View
  4. Double-click the button at the intersection of both rulers to access the properties of the form. In the Properties window, click the Format tab and click Picture
  5. Click the ellipsis button Ellipsis of the Picture property.
    If you receive a Microsoft Office Access Security Notice, read it and click Open
  6. Save the form

Linking or Embedding the Picture

After adding a picture to a form as its background, by default, the picture becomes part of the database. This is referred to as embedding the picture. The advantage is that, if/when you distribute the database, the picture would be added also and you do not have to worry about shipping it with the database. The disadvantage is that, (if you add many pictures like that) the database file gets larger and larger. Microsoft Access provides an option. Instead of embedding the picture, you can provide a link to it so that, whenever the form is opened, it would connect to the location of the picture and show it. The advantage is that, because only a link is provided, which is simple text, the database cannot grow because of the picture. The disadvantage is that, if/when you distribute your database, you must remember to also (separately) ship the picture and you must make sure the form can find the picture every time it is opened.

The embedding or linking characteristic is controlled by the Picture Type enumerated property whose two values are Embedded (the default) and Linked:

The Picture Alignment

In some cases, you may want to use a picture smaller than the form. Here is an example:

If you use a picture that is smaller than the form, by default, the picture would be positioned in the middle of the form. This characteristic is controlled by the Boolean Picture Alignment property whose default value is Center. If you want the smaller picture to be positioned in one of the sections, select another value from this property. If you select:

Practical Learning: Aligning the Background

  1. Set the Picture Alignment to Top Left
  2. Save and preview the form
     
  3. Close the form

Tiling the Picture

If you want to use a picture smaller than the form but have it repeat itself on the form, this characteristic is referred to as tiling. To make this happen, in the Format or the All tab of the Properties window, set the Picture Tiling Boolean property to Yes. Consider the following example:

If you set the Picture Tiling property to Yes, this would produce:

Zooming or Stretching a Picture

If you did not pay attention when designing the picture or if you got it from somebody, after specifying it as the background of the form, you may find out that either it is too narrow, too wide, too short, or too tall for the form. There are various ways you can manage this situation. One of the options you have is to control the size mode through the Picture Size Mode property.

Consider the following example:

 

Picture Size Mode is an enumerated property whose values are:

Characteristics of the Sections of a Form

 

The Background Color of a Section

In all forms we have created so far, unless using the Form Wizard or occupying it with a picture, the body of the form was painted with a white color. If you do not enjoy white forms, you can set the background to a color of your choice. Unlike the picture, the form (fortunately) does not control its background color. This aspect is left to each section to manage.

Before specifying the color of a form, first click or select the intended section. To change the background color of a section:

Unlike the Fill/Back Color (and the Font Color) of the Font sections of the Home and the Design categories of the ribbon, when you right-click a section of a form and position the mouse on Fill/Back Color, the colors that display do not show their tool tip, which would indicate their names. Because the layout of colors is the same as the Fill/Back Color and the Font Color windows of the Font sections of the Home and the Design categories of he ribbon, we will use their names.

Practical Learning: Setting Background Color

  1. The Central form should still be opened in Design View.
    On the form, click the Form Header bar to select its section
  2. On the ribbon, click Home.
    In the Font section, click the arrow of the Fill/Back Color button and select Dark Blue 5 (4th column - 6th row)
  3. On the form, right-click under the Detail bar, position the mouse on Fill/Back Color and click Medium Gray 2 (3rd column - 3rd row)
  4. On the form, double-click the section under the Form Footer bar
  5. In the Properties window, click the Format bar and click Back Color
  6. Click the arrow of the field and select Background Form
  7. To save the form, press Ctrl + S

Special Effects

Microsoft Access provides some special visual effects used to raise or sink, etc a section of a form or report, a label or a field. These effects can be controlled by using the Special Effect field in the Properties window.

Practical Learning: Using Special Effects

  1. The Central form should still be opened in Design View.
    On the form, click the Form Header bar
  2. In the Format tab of the Properties window, click Special Effect and click the arrow of the field to select Raised
  3. On the form, click under the Form Footer bar
  4. In the Format tab of the Properties window, double-click Special Effect to set its value to Raised
  5.  Save the form

Automatic Design of a Form

 

Microsoft Access Design Templates

We saw that, when you create a form using the Form Wizard, you have the option of applying one of the designs provided by Microsoft Access. If you create a form in Design View, you would have the regular design. You can still apply one of the designs supplied by Microsoft Access.

To use one of the pre-designs available in Microsoft Access

Creating a Form Design

If you design a good looking form and want to use its design in other databases, you can add it to the list of designs of the AutoFormat window. To do that:

In the Customize AutoFormat dialog box, you can click the Create A New AutoFormat Based radio button and click OK

Customize Input Mask Wizard

 

Dialog Boxes

 

Introduction

A dialog box is a rectangular object that is used to host or carry other controls:

A dialog box is primarily characterized by two features: its title bar and its body. The title bar, on top of the dialog box, can have a title and has the system close button . Although this is the normal appearance of a dialog box, it is not strictly exclusive. Some dialog boxes display the system icon. On the right side of the title bar, a classic dialog box displays only the system Close button made of X. Again, this is not exclusive. It is not unusual for a dialog box to display the minimize and the maximize/restore buttons. To use a dialog box, the user must open it one way or another. Your job is to decide how and when the user will be able to open a dialog box.

Creating a Dialog Box

There are various ways you can create a dialog box in Microsoft Office Access 2007:

There are two types of dialog boxes: modal and modeless.

Practical Learning: Creating a Modal Dialog Box

  1. From the resources that accompany these lessons, open the Bethesda Car Rental1 database
  2. On the Ribbon, click Create and, in the Forms section, click Form Design
  3. Double-click the button at the intersection of the rulers to access its properties.
    In the Properties window, click the Format tab and click Border Style. Then click the arrow of the Border Style field and select Dialog
  4. Switch it to Form View to preview
  5. Save the form as RentalRates and switch it back to Design View
  6. In the Properties window, click the Format tab and click Caption
  7. Type Bethesda Car Rental - Rental Rates and press Enter
  8. Click Width. Type 4.375 and press Enter
  9. To complete the dialog box, in the Format tab of the Properties window, change the following properties:
    Auto Center: Yes
    Record Selectors = No
    Navigation Buttons = No
  10. Click the Detail bar to select it. Then, in the Format tab of the Properties window, click Height. Type 1.875 and press Enter
  11. Preview and save the form
  12. Switch it back to Design View

Modal Dialog Boxes

A dialog box is characterized as modal if the user must close it before continuing with another task on the same application.

In order to use a dialog box in your application, you should analyze a scenario and define if the dialog box is necessary. Use a dialog box if you want the user to first terminate whatever task he or she would be performing. For example, if a user is performing a payment of an order processing, it is natural to process and finish that payment before starting another task.

A classic (or normal) dialog box would need neither a Record Selectors bar nor the record navigation buttons. Therefore, you should decide how the dialog box would be used. If you want a regular dialog box as those available on non-database applications, you should set the Record Selectors, the Navigation Buttons and the Dividing Lines properties to No each.

Modeless Dialog Boxes

A dialog box is referred to as modeless if the user does not have to close it in order to continue using the application that owns the dialog box. The Find dialog box of most applications is an example of a modeless dialog box. If it is opened, the user does not have to close it in order to use the application or the document in the background.

Since the modeless dialog box does not display its button on the task bar, the user should know that the dialog box is opened. To make the presence of a modeless dialog box obvious to the user, it typically displays on top of its host application until the user closes it.

To create a modeless dialog box, or to convert a form into a modeless dialog box, in Design View, set the Popup property (Other and All tabs) to Yes. This makes sure that the user can work on another form and the modeless dialog box or form would remain on top of any other form of your database.

Practical Learning: Creating a Modeless Dialog Box

  1. The Bethesda Car Rental1 database should still be opened with the Rental Rates dialog box in Design View.
    To make it a modeless dialog box, in the Properties window, click the Other tab. Double-click Pop Up to change its value from No to Yes
  2. Save and close the Rental Rates dialog box

Lesson Summary

 

MCAS: Using Microsoft Office Access 2007 Topics  
C5 Create forms
C7 Modify the design of reports and forms
E2 Navigate among records
 

Exercises   

Yugo National Bank

  1. Open the Yugo National Bank1 database
  2. Configure the database to display in overlapping windows

Watts A loan

  1. Open the Watts A Loan1 database
  2. Configure the database to display in overlapping windows

Previous Copyright © 2008-2016, FunctionX, Inc. Next