FunctionX

Forms Fundamentals

Overview of Forms

Introduction

A form is a rectangular object used to host, carry, or hold other objects that serve for interaction between a user and the database application. As such,  a form by itself means nothing. The objects positioned on it play the main role. As a normal Microsoft Windows window, a form shares many of the characteristics of other containers.

There are various techniques used to create a form in Microsoft Access. To start, forms can be divided in two broad categories: standalone and record-dependent forms.

Practical Learning: Introducing Forms

  1. If you want to follow, open the Domba Ice Cream database
  2. Click Forms to activate the Forms section

Record-Independent forms

A standalone form is one whose fields don't depend on records stored in tables nor originate from a SQL expression. To create such a form, you can display the New Form dialog box, select Design View and delete the contents of the combo box if it contains anything. Even if the form has already been created and that it gets values from a table or a query, to make it standalone, delete the contents of its Record Source property.

Practical Learning: Creating Standalone Forms

  1. To create a standalone form, on the main menu, click Insert -> Form
    In the New Form dialog box, make sure Design View is selected and the bottom combo box is empty
     
    New Form
  2. Click OK
  3. To save the form, press Ctrl + S
  4. Type Switchboard as the name of the form and click OK
  5. Close the form

The Form Wizard

Another type of form we mentioned is one whose information is stored in a table, in tables, in a query or from a SQL statement. One of the easiest ways to create such a form is by using the Form Wizard. The wizard allows you to select the columns from an existing table, a query or a combination of such objects.

Practical Learning: Using the Form Wizard

  1. On the main menu, click Insert -> Form
  2. In the New Form dialog box, double-click Form Wizard
  3. In the first page of the wizard, in the Tables/Queries combo box, select Table: Employees
  4. In the Available Fields list box, click the select all button and click Next
  5. In the second page, make sure the Columnar radio button is selected and click Next
  6. In the third page of the wizard, click Standard and click Next
  7. In the fourth page, accept the suggested name as Employees and click Finish
  8. Close the form

The AutoForm

A very fast means of creating a form is through a feature called AutoForm. To use it, in the Tables or Queries section of the Database window, you can first click the object that holds the information. Then, click the New Object: AutoForm button on the Database toolbar. Alternatively, you can first display the New Form dialog box. In it, you can select one of the AutoForm options and an object in the bottom combo box. When you click OK, just as when you click the New Object: AutoForm button on the Database toolbar, a new form would be generated.

Practical Learning: Using AutoForm

  1. To use AutoForm, on the main menu, click Insert -> Form
  2. In the New Form dialog box, click AutoForm: Columnar
  3. In the bottom combo box, select CustomersOrders and click OK
  4. Press Ctrl + S to save the form
  5. Accept its name as CustomersOrders and click OK
  6. Close the form

Characteristics of Forms

Introduction

Like all or most regular windows, a form starts on top with a title bar. Although a form is by default equipped with a title bar, for any reason you judge necessary, you can remove it. While you may allow the user to be able to minimize or maximize a form, you may want to present one or both of these actions for the user. As an application design environment, Microsoft Access provides most of the features you will need for a regular and even advanced database product.

Most of the Characteristics of a form can be configured using its Properties window. After displaying the form in Design View, you can get its Properties window by double-clicking the button at the intersection of both rulers

Form Centering

If you either create a new form or modify the design of an existing form, when you save it, Microsoft Access saves the position of the form then would remember and restore that position the next time you reopen the form. Alternatively, you can ask Microsoft Access to position the form in the center of the screen the next time you open the form, even if it was on one corner of the screen when you saved it.

To center the form by default whenever it comes, set its Auto Center Boolean property to Yes. 

The Title Bar

The top section of a form is its title bar. It displays an icon on the left side. The system icon is fixed and you should not spend time trying to change it. The system icon holds a menu that allows the user to perform the regular operations of a Windows container, including minimizing, maximizing, restoring or closing the window. To display this menu, the user can click the form’s system icon:

The presence of the form’s system icon is partly controlled by the Control Box property of a form. In most cases, you should make this system icon and its menu available to the user. If for any reason you don't want to provide this functionality, set the Control Box property to No. The form would appear as follows:

If you decide to do this, make sure you provide the user with the ability to close the form and this type of title bar makes it impossible. Of course, a user may know that the form can be close by clicking the Close menu item under the File group of the main menu or by pressing Ctrl+F4.

The middle section of the title bar is actually referred to as the title bar. It can be used to change the view of the form after right-clicking it. The title bar uses a color set in the Advanced Appearance of Control Panel as Active Title Bar.

Practical Learning: Using the Form’s Title Bar

  1. Open the CustomersOrders form. Right-click its title bar and click Design View
  2. Double-click the button at the intersection of both rulers to open the form’s Properties window. In Properties window, click the Format property page and click Caption
  3. Type Domba Ice Cream - Customers Orders and press Enter
  4. Switch to Form View to preview the form
  5. Switch it back to Design View

The System Buttons

The right side of the form’s title bar displays three system buttons , or , . 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 without the system icon and the system buttons as seen above. Once again, if you do this, make sure the user has a way to close the form.

Practical Learning: Configuring the Form’s System Buttons

  1. The CustomersOrders form should still be opened
    In the Properties window, click the Min Max Buttons field. Click its arrow and select Min Enabled
  2. Switch to Form View to preview the form and try to maximize the form
  3. Save and close the form

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:

The Form's Width

A form displays on the screen using its dimensions. These are the width and height. The form itself controls only the width. The height is controlled by its sections. To change the width of a form, on the Properties window, type the desired decimal value in the Width field of the Format property page.

The Form's Sections

The most obvious part of a form is an area called Detail. This section starts on a bar labeled Detail and ends at the bottom unless a new section starts. The Detail section serves as the main host of other controls. It can also serve to display messages of various kinds. The Detail section can be enhanced by manipulating its properties. These properties are not necessarily related to the parent form but can be used conjointly with it.

As mentioned already, a form itself controls its width. The vertical dimension of a form is controlled by its sections. The vertical measurement of the Detail section is controlled by the Height property. There are two main ways you can change the Detail section's height at design time:

Besides the Detail section, a form can be enhanced with one or two more sections: Header and Footer. By default, the Header and Footer sections are created on a form if you use the Form Wizard.

To add the Header and Footer on a form that doesn't have them, you can use the menu bar where you would click View -> Form Header/Footer. Probably the fastest way to add these sections is by right-clicking anywhere on the form and clicking Form Header/Footer. If the form already has these sections but they don't contain anything, they would be removed. If the form already has these sections and they contain anything, you would receive a warning:

If you still want to delete the Header and Footer sections, you can click Yes; this would un-recoverably delete their content. Like the Detail section, the Header and Footer sections control their own height, which you can change the same way we did previously. This also applies for the Back Color property. The Special Effect property allows you to raise or sink a section.

Practical Learning: Designing the Header and Footer Sections

  1. Open the Switchboard form and switch it to Design View
  2. To add new sections, right-click anywhere in the form and click Form Header/Footer
  3. Save, preview, and close the form

Record Selectors

The Record Selector is a vertical bar on the left side of a form. It allows the user to select all of the fields’ contents of one or more records and copy them to the clipboard. Such a selection can then be pasted to another record, other records, or to a text or another type of file (for example you can paste the record in Notepad, Microsoft Word, Microsoft Excel, or any text file).

There are two reasons you would use record selectors on a form. If you want the user to be able to access all fields of a record as a whole, make sure that the form is equipped with record selectors. In the same way, you can hide the scroll bar if the user would not need them. Another reason you would use a record selector is for aesthetic reasons. Most of the time, if designing a form for data entry, you would mostly allow the presence of record selectors. If you are designing a dialog box that would display the same content all the time, you should not allow the record selectors.

The presence or absence of record selectors is controlled by the Boolean Record Selectors property field. If you set the field value to Yes, then the form would display the record selector. Setting the field value to No would hide the record selectors.

Practical Learning: Hiding the Navigation Buttons

  1. Open the Switchboard form and notice that it is equipped with a bar on the left
  2. Switch the form to Design View
  3. In the Format tab of the Properties window, double-click Record Selectors to change its value from Yes to No
  4. Switch the form to Form View to preview it
  5. After viewing the form, save it back to Design View

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 allows scrolling left and right.

By default, scroll bars come up if the form "judges" that 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 vertical 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 don't want any scroll bar, set the Scroll Bars property value to Neither.

Navigation Buttons

A form is equipped with some buttons on its lower section. These buttons allow the user to navigate back and forth between records. These buttons are very useful during data entry and data analysis. If you are creating a form that would display the same content all the time, such as a form that does not actually display records, you can hide the form navigation buttons.

The presence or absence of navigation buttons is controlled by the Boolean Navigation Buttons property. When its value is set to Yes, the form would display the Navigation Buttons. To hide them, set the Navigation Buttons property value to No.

Practical Learning: Hiding the Navigation Buttons

  1. The Switchboard form should still be opened in Design View
    In the Format tab of the Properties window, double-click Navigation Buttons to change its value from Yes to No
  2. Switch the form to Form View to preview it. Notice the absence of navigation buttons
  3. After viewing the form, save and close it

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 function. They can be useful on a continuous form.

To equip a form with dividing lines, add a header and a footer sections. On the other hand, 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. Its default value is Yes, which means that the dividing horizontal lines would display on the form. To hide both lines, you can set its value to No. To hide an individual line, you can completely reduce its section.


Copyright © 2002-2004-2019, FunctionX, Inc.