Tuesday, September 14, 2010

Access Form and Control

A form object in MS Access provides a convenient method for entering, editing, and displaying records. Forms allow you to view data one record at a time, in a more attractive format than Datasheet view for tables and queries.

Forms can be created using fields from either a table or a query. The data that is added to the form will be added to the table or query that the form is based on, and vice versa

Like tables and queries, forms can be opened in two views: Form view, which displays actual data, and Design view, which you use to create or modify the structure of the form. In Design view, you can customize your forms by adding or removing fields, changing the background color or pattern, or selecting from several form layouts.

In Access, tables are built from fields and records. Similarly, the building block of the form is the control. Controls are more flexible than the fields and records that make up tables. They can contain data, perform an action, or enhance the design of the form by adding graphic elements such as lines or rectangles.

Different kinds of Controls in a form  

A label box is a control you use to display text that a user can't edit directly. 

A text box is used to display information entered at design time, by a user at run-time, or assigned within code.

Check boxes provide a way to make choices from a list of potential candidates.  Some, all, or none of the choices in a group may be selected.

Option buttons provide the capability to make a mutually exclusive choice among a group of potential candidate choices.  Hence, option buttons work as a group, only one of which can have a True (or selected) value.

Option group provide a way of grouping related controls on a form. 

A list box displays a list of items from which the user can select one or more items.  If the number of items exceeds the number that can be displayed, a scroll bar is automatically added.


The combo box is similar to the list box.  The differences are a combo box includes a text box on top of a list box and only allows selection of one item.

The line tool creates simple straight line segments of various width and color.  Together with the shape tool discussed next, you can use this tool to 'dress up' your application.

The shape tool can create circles, ovals, squares, rectangles, and rounded squares and rectangles.  Colors can be used and various fill patterns are available.

An image box is very similar to a picture box in that it allows you to place graphics information on a form.  Image boxes are more suited for static situations - that is, cases where no modifications will be done to the displayed graphics.

The easiest way to create a form based on the table or query that you select is to use AutoForm. Although AutoForm creates forms quickly, this technique does not give you a lot of control over the content or appearance of the form.

AutoForm creates a form with controls for all the fields from the table that the form is based on, so you do not have a chance to select fields individually. However, after you create a form using AutoForm, you can modify and enhance the form in Design view.

AutoForm offers three layouts for your form: columnar, tabular, and datasheet.

In columnar layout, only one record can be viewed at a time. Text boxes and their associated labels appear side by side in two columns. The labels appear to the left of each text box and identify the data in the text box.

In tabular layout, labels appear across the top of the form, and the values for each field appear in columns below the labels. In tabular layout, more than one record can be displayed at a time.

Datasheet layout displays records in columns and rows, so the form looks similar to tables displayed in Datasheet view. Some of the form enhancements available with columnar and tabular layouts cannot be used in datasheet layout.


0 comments: