Simple Forms

Document Sample
Simple Forms Powered By Docstoc
Forms are used mainly for data entry and to control what the user can change. There are three
ways to create forms: an AutoForm, using the Form Wizard, and using Design View only.

For the purposes of the Sample Database at this time, the forms for the data entry of the
Customer, Genre, Rental Terms, and Movies information will be created.

The AutoForm feature will create a form based on the selected table, using all fields, and the
default style of the forms. There is no control over which fields are included (or not until the
form is completed). The AutoForm is a great way to get a data entry from created quickly and
easily. Then it can be modified to suit any purpose.

New Object
The fastest way to create an AutoForm is to use the New Object button on the Database Toolbar.

1) Begin by selecting the table on which you want to base the form. (tblCustomers in the
   Sample database)
2) Then click on the New Object drop down list and select AutoForm (by default, it should be
   the button on the New Object tool)

3) The new form is created and presented immediately:

Forms                                                                                              1
4) Each of the captions that were set in the table are shown in the labels on the form. The form
   is created with all fields from the table, set up in a columnar layout, and in the default style
   (or the last style of form used – Standard, Stone, Clouds, International etc)
5) Save the form as frmCustomers
6) Test the form by entering the following record:
   Sarah Stone, The Sliver Estates, Hollywood CA 11403, (213)555-3737

AutoForm: Tabular
Another format of AutoForm is a tabular form. A tabular form shows many records at one time
in rows, with the fields arranged in columns. Much like a datasheet view, it is useful for
comparing several records at one time. The tblGenre and tblRentalTerms would both suit a
tabular form.

To create a Tabular AutoForm:

1) Click on the Forms Tab

Forms                                                                                                 2
2) Click on the New button to get the New Form dialog box:

3) Select AutoForm: Tabular from the list of possibilities, then select the tblGenre from the
   drop down list of tables. Click on OK to finish the form creation:

4) Each record that has been entered into the table so far shows up in the form. The AutoForm
   Tabular feature creates a form from all fields, with the default style. The result is fully
   functional, but rather boring.

Form Wizard
The Form Wizard offers more control over the form creation process. The Form Wizard allows
for selecting which fields are to be included in the form, the layout of the form, and the style of
the form.

The New Object button
The Form Wizard can be started from the New Object button.

Forms                                                                                                 3
1) Select the desired table in the Table window (tblRentalTerms) and click on the Drop Down
   arrow to the right of the New Object button

2) Select the Form option to get the New Form dialog box (the form icon has a spangle or star
   on it)

Forms                                                                                           4
3) Click on the Form Wizard choice then click on OK

4) The first of the Form Wizard dialog boxes allows you to select which of the fields you want
   to include on your form. Select all except for the RentalTermID field.
    To select a field, click on it in the left column, then click on the > button to move it to the
       right column.
    You can also double click on a field in the left column to move it to the right column.
    To select all fields, click on the >> button.
    The fastest way to select all but one field is to select them all, then send the field you
       don’t want back to the left column using the < button.

Forms                                                                                              5
5) Click on Next to go to the next screen:

Forms                                        6
6) This screen gives you the chance to select the desired layout for your form. Columnar is
   like the form created for the customers table, Tabular is like the form created for the genre
   table, Datasheet looks like a table and Justified arranges each field so that it touches the
   next. For this form, select the Tabular option, then click on Next:

7) In this screen, select the style you want for your form (the colours, background image, fonts,
   etc.). The sample has selected Colorful 2 as a style, but it is recommended that you stick
   with Standard as the style. Standard uses the Windows colours to create the form, and
   therefore saves on file size and system resources. If your database is fairly large to begin
   with, don’t make the file unneccessarily larger by selecting a fancy style for each form.
   Click on next to continue:

Forms                                                                                               7
8) This last screen in the wizard (hence the checkered flag to indicate that you have reached the
   finish line) asks you for a name for the form. This name will be used in two places: as the
   title of the form (in the title bar) and as the saved name of the form (as it will appear in the
   database window. Generally, it is accepted practice to supply the name you want for the
   name of the form and change the caption property of the form to change the text in the title
   bar of the form. In this case, name the form frmRentalTerms. This is the finished form:

Forms                                                                                                 8
The New Form Dialog Box
The Form Wizard can be started directly from the Forms tab, by clicking on the new button to
get the New Form dialog box:

                              Forms Tab
                                                                New Button

        New Form
        dialog box

1) For the purposes of this exercise, create a new form based on the movies table:

2) Select all fields except for the MovieID:

Forms                                                                                          9
3) Select the Columnar layout

4) Selct the style of your form (Standard in this case)

Forms                                                     10
5) Supply a title for your form (frmMovies)

Forms                                         11
6) This is the finished form:

As with all Wizard-Produced objects, all of the completed forms are close to what we want, but
not quite. There are a few changes to be made: the form needs a title; the Rating, Genre and
Retail Price fields are too long, and the form could be made more interesting and natural by
rearranging the fields. These types of changes are made in Design View.

Design View
This is the construction area for Forms. To get to design view, either open the form and click on
the Design View button on the Forms toolbar


Select the form from the Forms tab and click on the Design button:

Forms                                                                                          12
Design view looks like this:


                                                         Design Grid

                   Section Divider

                                                                          Tool Box

The rulers (horizontal and vertical) are used to accurately position and size the objects on the
screen. They are also used to select all objects in a line across or down the window.

Design Grid
The design grid indicates the working area of the form. The size of the grid determines the size
of the finished form. If there is a lot of extra space in the grid, then there will be a lot of extra
space in the form. To turn off the gridlines (the lines every inch and the dots between them),
click on the View menu and choose Grid.

Forms                                                                                               13
Section Divider
The section dividers help you in the design process to determine where all the elements of a form
are placed. Elements placed in the Form Header section appear at the top of the form, no matter
how large the form is, that information always stays visible. Elements placed in the Form Footer
section appear at the bottom of the form no matter how long the form is. Elements placed in the
Detail Band (or section) will repeat for each record in the dataset.

To turn the Form Header/Footer on or off, use the View Menu.

To open up more space in any section, carefully place your pointer on an edge of a section
divider and drag down. To open more space in the Form Header, place your mouse between the
Form Header and Detail section dividers, and when the mouse changes to a horizontal line with
arrows pointing up and down, click and drag down.

To open more space in the Detail band, drag the top of the Form Footer divider down. To open
more space in the Form Footer, drag the bottom of the Form Footer divider down.

The toolbox is a floating toolbar that can be docked at any side of your screen if you so desire.
The toolbox is available in the View menu – Toolbox, or on the toolbar as the button with the
crossed hammer and wrench. The toolbox contains all the tools you will need to modify your
forms in any way you want. To use a tool, simply click on the tool to make it active, then click
in the form where you want to use the tool. As the use of each tool is explored, more details will
be made available.

Forms                                                                                           14
The Controls
On the form, the fields in the tables appear as pairs of objects. For each field there is a Control
and a Label. The Control is the "blank space" on the finished form, the area for the data. The
Label is the descriptive text attached to the control. The descriptive text is taken from the
Caption property of the field in the table. If the caption is not defined, then the label is the same
as the field name.

        Labels                                                                          Controls

You can change the text inside a Label, but you CANNOT change the text inside the Control (to
do so is to break the connection back to the field in the table).

Selecting Objects
Everything in an Access form is an Object. You can select an object by simply clicking on it.
When you select a control on a form, both the control and the label are selected as a pair. The
object that you clicked on will have the 8 selection handles around it, its partner will only have
the top left selection handle.
                                                                           One of 8 regular
           Selection handle                                                selection handles
               of label                       Selected Control

To select multiple objects, you have several choices:
   a) Click on the first object, press and hold the Shift Key on the keyboard and click on each
       other object you wish to include.


Forms                                                                                                15
   b) If the objects are all beside each other, then you can simply draw a Marquee around the
      desired objects. Using just the pointer tool, begin to draw a box in an empty space on the
      form; drag the mouse to the diagonally opposite corner, and release when all desired
      objects have been included.

    Marquee Line

                                         Begin in this empty space

Moving, Sizing
Once the objects have been selected, you can position them on the form any way you would like,
and change their size to suit your needs.

To Move Objects
To move the pair of objects (the control and the label) position your mouse pointer over the
      selected object. The pointer will change to an open hand (called the Grabber Hand).
      This tool will allow you to move the pair of objects.

To move the Control or Label only, select either the control or the label. Then point to the top
      left selection handle (the larger square) of the object you want to move. The pointer will
      change to a hand with a pointing finger. This tool will allow you to move just the one
      part of the pair of objects.

To align objects with one another, use the Align feature. Select all desired objects, then from the
       Format menu (or Right Click any selected object) select Align, then select how you want
       the objects to be arranged. Only the objects surrounded by the selection handles will be
       affected by the align feature. Warning: if you choose to align objects that overlap, it is
       possible that the alignment will not work as anticipated. If this happens, simply Undo the
       alignment, rearrange the objects so that they do not overlap, and try to align them again.

To change the Spacing between objects, use the Horizontal Spacing and Vertical Spacing
       features. Begin by selecting the desired objects. It is usually best to have the spacing
       adjusted so that all spaces are equal before increasing or decreasing the amount of space.
       To do this, choose the Format menu, then choose the appropriate Spacing option, and
       choose Make Equal. All selected objects (this feature works on both the control and the
       label, no matter which is selected) should now be spaced the same distance apart in the

Forms                                                                                           16
        direction you selected. If objects overlap or touch each other, then the Make Equal
        feature can cause undesirable results. If this occurs, simply Undo the spacing, make a
        few adjustments, and try the spacing again.

To Change the Size of Objects
Select the object you wish to modify.

To change the height of the object, point to either the top center or bottom center selection
       handles. The pointer will change to an arrow with two heads (pointing up and down).
       Drag the handle in the direction you wish to go.

To change the width of the object, point to either of the side center selection handles. The
       pointer will change to an arrow with two heads (pointing left and right). Drag the handle
       in the direction you wish to go.

To change both the height and width of an object, use one of the three other corner selection
       handles (not the top left - that is reserved for moving objects). The pointer will change to
       an diagonal double-headed arrow. Drag the handle in the direction you wish to go.

To change the size of multiple objects, simply select all the desired objects before dragging a
       selection handle. All objects will maintain their "relative" size to each other.

To automatically make all selected objects the same size, use the Size feature. From the Format
       menu (or Right Click any selected object) select Size, then select how you want the
       objects to be resized. To Tallest makes all the objects the same height as the tallest
       selected object. To Widest make all the objects the same length as the longest selected

Many of the physical properties of the objects (size, colour, style, font, font size, font colour,
alignment of text, border style, etc) can be modified by using the Formatting toolbar. To do this,
select the object then make the desired changes (such as border style, font, size, font style).

Open the Properties Window by one of the following methods:
   a) View menu - Properties
   b) Properties button on the Standard Toolbar
   c) Right Click on an object and select Properties from the quick menu
   d) Double click on an object (only if it is not selected to begin with)

The Properties Window is divided into 5 tabs - with similar properties grouped on each tab. The
last tab - All - contains all the properties on the other tabs combined into one list. Changes can
be made in either location, whichever one is easiest for you to find. The specific properties that
are available will change for each type of object selected. Many of the properties (like Caption,
Format, Default Value, Input Mask, and Validation Rules) are the same as for the Table
properties (beginning page Error! Bookmark not defined.22). The following is a list of some
of the more commonly used properties of the forms:

Forms                                                                                             17
This property will show or hide a control, a section of the form, or the entire form. Useful when
fields have to be used on a form to make it easier to perform calculations, but don’t need to be
displayed to the user.

Control Source
This property determines which field the control is tied to. In other words, where in the
underlying table is this control getting its data? A control can also be unbound. This type of
control is used for calculations or expressions.

This property allows the user to click in this control or not. When the enabled property of a
control is set to No, the information appears on the form, but it appears as a dimmed or grayed
out object, indicating that it is not available for change. In the example below, the Movie Name
control has it's enabled property set to No.

This property prevents the user from making changes to a field, but the field maintains its
appearance (it looks normal, not dimmed). In the example below, the Movie Name control ha s
its Locked property set to Yes:

Tab Stop
The Tab Stop property determines if the control can get focus when the user presses the Tab key.
This does not stop the user from making changes to a field.

Forms                                                                                            18
Tab Index
The Tab Index property determines the order in which the Tab key will move among the controls
on the form. By default, the order is from left to right, top to bottom, through the controls as
they are first placed on the form. As you make changes to the arrangements of the controls, you
may want to adjust the Tab Index property to give the form a more natural feel.

ControlTip Text
Any text you type into this property will appear in a little yellow box when the user points to the
control on the form. This is used to give hints and information about the type of information that
you want input into a control. In the following example, a Control Tip has been given to the
Rating Field:

Change To
Change To is a built in formatting feature
that makes it easy to modify the nature of
controls. For example, in a form for
looking up the information on a movie, you
would not want to change any of that
information. One of the ways to avoid
unwanted change is to convert a combo box
(such as the Rating or Genre fields) to a text
box (getting rid of the tempting drop down
arrow in the process). Change To is on the
Format menu. The choices available
depend on the type of the control that is
selected. In the following example, the
Genre combo box is selected, offering the
choice of either a list box or a text box on
the Change to list.

Forms                                                                                            19
Tab Order
Tab Order determines how the Tab key will move the focus through a form. When each form
opens, the first field in the Tab order is selected. As the user presses the Tab key, the next field
in the list is selected. The Tab Order is determined by the Tab Stop and Tab Index properties of
each field.

The Tab Order dialog box provides an easier method of modifying the tab order on a form. To
open the Tab Order dialog box:
   a) View Menu, Tab Order
   b) Right click anywhere on the form and select Tab Order

To modify the Tab Order, you can choose to click on the Auto Order button in the bottom right
hand corner of the dialog box to put the controls in a natural, left to right, top to bottom order. If
this does not suit your needs, then you can click and drag on the gray boxes beside each control
listed in the Custom Order box to rearrange them. As you drag the boxes up and down the list,
watch where the solid black line is - this will determine where the control will be placed when
you let go of the drag.

Adding Titles
To add a title (or any other descriptive text) to a form, use the Label tool in the toolbox. Click on
the label tool to activate it, then click and drag a marquee in the form where you want the title to
be placed. Type the desired text. Press Enter to accept the text, then use the formatting tool bar
and other properties to enhance the appearance of the title.

Forms                                                                                               20