Tuesday, June 11, 2013

Other Characteristics of a Form

Tags

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. You can almost any (type of) picture your want.
To use a picture as a background, open the form in Design View:
  • On the Ribbon, click Format. In the Background section, click Background Image. A window/menu would come up. If you had previous selected some pictures, they would appear in that window. Otherwise, click Browse... Locate the picture you want, select it, and click Open
  • Access the Properties window for the form. In the Format or the All tab, 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 popular picture formats, including BMP, JPEG, GIF, and PNG. 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:

Background Picture
This would produce:
Background Picture
Practical Learning: Setting the Background of a Form

  1. Start Microsoft Access
  2. From the resources that accompany our lessons, open the Danilo Pizza1 database
  3. In the Navigation Pane, under Pizza Orders, double-click (the) Pizza Orders (form) to open it
  4. After viewing the form, to change its view, right-click its tab and click Design View
  5. On the Ribbon, click Format
  6. In the Background section, click Background Image and click Browse...
  7.  From the resources that accompany these lessons, locate the Pizza.jpg picture
     
    Insert Picture
  8. Click OK
  9. 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:
  • If you set the Picture Type to Linked, the file name of the picture (with its extension) would be set as the value of the Picture property
  • If you set the Picture Type to Embedded, you would be asked to first remove the value of the Picture property. You must specify the picture again. This time, the (whole) path of the file name would be set as the value of the Picture property. 
The Picture Alignment

In some cases, you may want to use a picture smaller than the form. Here is an example:
Background Picture
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:
  • Top Left: If the form has only a Detail section, the picture would be positioned from under the Form Header bar but to the left side of the section.
    If the picture is taller than the Form Header section, it would span down to the Detail section

    Top Left

    If you want such a picture to display only in the Form Header section, when designing it, make it shorter and set the height of the Form Header section accordingly
  • Top Right: If the form has only a Detail section, the picture would be positioned from under the Form Header bar but to the right side of the section:

    Top Right

    If the picture is taller than the Form Header section, it would span down to the Detail section. If you want such a picture to display only in the Form Header section, when designing it, make it as tall as the intended height of the Form Header section
  • Center and Form Center: The picture would be positioned in the middle of the Detail section
  • Bottom Left: If the form has only a Detail section, the picture would be positioned above the Form Footer bar to the left side of the section.
    If the picture is taller than the Form Header section, it would span up to the Detail section



    If you want such a picture to display only in the Form Footer section, design it and make it as tall as the eventual height of the Form Header section
  • Bottom Right: If the form has only a Detail section, the picture would be positioned above the Form Footer bar to the right side:

    Bottom Right

    If the picture is taller than the Form Header section, it would span up to the Detail section. If you want the picture to display only in the Form Footer section, when designing it, make it as tall as the height you will specify for the Form Header section
Practical Learning: Aligning the Background

  1. In the Properties window, click Format. Click Picture Alignment and select Top Left.
    Save and preview the form

  2. 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:
Picture Background
If you set the Picture Tiling property to Yes, this would produce:
Picture Background
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 Background

Picture Size Mode is an enumerated property whose values are:
  • Clip: This is the default value. Its effect depends on the Picture Alignment and the Picture Tiling properties
  • Stretch: When this option is selected, the picture size would be expanded so that its corners (top-left, top-right, bottom-right, and bottom-left) touch the corners of the form. Here is an example:

    Picture Background

    If the form is resized, the background picture would be stretched so its corners are the same as those of the form. Here is an example of the above form resized:

    Picture
  • Stretch Horizontal: When this option is selected, the picture would be expanded horizontally so that its left border touches the left border of the form and the right border of the picture would touch the right border of the form. If the form is resized, the background picture would be stretched also. Its left and right borders would still touch the left and right borders of the form
  • Stretch Vertical: If this value is set, the picture would be heightened or shortened so its top border touches the top border of the form and the bottom border of the picture would touch the bottom border of the form. If the form is resized, the picture would be stretched also: its top and bottom borders would correspond to the top and the bottom borders of the form
  • Zoom: To start, Microsoft Access would get the height and the width of the picture, then it would calculate their rate to get a fraction such as 1/2, or 3/4, or 7/5, etc. When this option is selected, the picture would be stretched proportionally using the calculated rate. When stretching, once a border of a picture reaches a border of the form, the other border would not be stretched anymore. As a consequence, if the rate of the dimensions of the form is not the same as the rate of the dimensions of the picture, two sides of the form would not be covered. Consider the following:

    Picture Background

    Notice that the picture is square, which means the rate of its height and width is 1. The form is rectangular, which means the rate of its height and width is different than 1. If you set the Picture Size Mode property to Zoom, you would get the following result:

    Picture Background

    If you resize the form, the picture also may be stretched but it would keep the rate of its height/width
 
   
 
Characteristics of the Sections of a Form

 
Inroduction to the Colors of Sections

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 don't 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.

The Background Color of a Section

Before specifying the color of a form, first click or select the intended section. To change the background color of a section:
  • On the Ribbon, click Home and, in the Text Formatting section, select a color from the Background Color button Fill/Back Color
  • Right-click a section, position the mouse on Fill/Back Color and click the desired color

    Fill/Back Color
  • On the Ribbon, click Format. In the Control Formatting section, click the Shape Fill button Fill/Back Color
  • Access the Properties window of the section. In the Format or the All tab, click the Back Color field. If you click the arrow of the property, you can select a familiar color from the list
     
    Back Color

    Otherwise, you can click the browse button. This would display a list of colors similar to that of the Font/Fore Color window
Unlike the Background Color (and the Font Color) of the Text Formatting 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 Background 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 Background Color and the Font Color windows of the Text Formatting sections of the Home and the Design categories of he Ribbon, we will use their names.

Practical Learning: Setting Background Color

  1. Open the Hotel Management1 database from the previous lesson
  2. In the Navigation Pane, right-click Central and click Design View
  3. On the form, click the Form Header bar to select its section
  4. On the Ribbon, click Home
  5. In the Text Formatting section, click the arrow of the Background Color button and select Dark Blue 5 (4th column - 6th row)
  6. 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)
  7. On the form, double-click the section under the Form Footer bar
  8. In the Properties window, click the Format bar and click Back Color
  9. Click the arrow of the field and select Background Form
  10. To save the form, press Ctrl + S
The Alternate Color of a Tabular Form

If you decide to create a tabular form, you can make all rows show their backgrounds in the same color
Alternate Background Color
As an alternative, you can make even rows show their background in one color and odd rows show their background in another color. To do this, display the form in Design View, click the Header bar and set the desired color using any of the techniques we saw above. That color would apply to the odd rows. To specify the color of the even rows:
  • On the Ribbon, click Format. In the Color Formatting section, click the arrow of the Alternate Row Color button and proceed to select or create a color as we described already for the background color
Alternate Row Color
  • Right-click the Header bar or an empty area in the header section, position the mouse on Alternate Fill/Back Color and select a color from the window
  • Access the Properties window of the header section. In the Format or the All tab, click the Alternate Back Color field. Use either the arrow of the combo box to select a color by name or use the ellispsis button to select color by viewing it
Here is an example:
Alternate Background Color
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

 
Using a Theme

If you create a form in Design View, you would have the regular design. You can apply one of the designs supplied by Microsoft Access.
To use one of the pre-designs available in Microsoft Access, open the form in either the Design View or the Layout View (to do this, in the Navigation Pane, you can right-click the form and click Layout View. If the form is currently opened, on the right side of the status bar, you can click the Layout View button). On the Ribbon, click Design if necessary. In the Themes section, click the Themes button. This would display a window with the available themes:
Themes
By default, the window displays 1 and 16 themes. To show more, click the down-pointint arrow or use its scroll bar to navigate. Each theme has a name that appears as a tool tip when you position the mouse on it. To apply one of the themes to your form, simply click it. If you have other themes on the computer, you can click Browse For Themes, locate the desired theme and select it.
After selecting a theme, you make not like some of its colors. You are free to change any aspect on the form. After making changes, if you like the new display and you want to keep it for future use, on the Ribbon, click Themes and click Save Current Theme.

Using a Group of Preset Colors

One of the ways you can make the design of a form appear professional is to coordinate colors. To assist you with this, Microsoft Access provides a series of coordinated colors you can directly apply to your form. Before using this option, open the form in Design View or in Layout View. On the Ribbon, click Design. In the Themes section, click Colors and select from the list:
Theme Colors

Using a Group of Preset Fonts

Microsoft Access provides an option to apply a group of fonts to various objects on a form. To use it, open the form in Design View or in Layout View. In the Themes section of the Design tab of the Ribbon, click the arrow of the Fonts button and select one of the options from the window.

Dialog Boxes

 
Introduction

A dialog box is a rectangular object that is used to host or carry other controls:
Dialog Box
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 2010:
  • To let the application generate a dialog box for you, on the Ribbon, click Create:
    • In the Forms section, click More Forms -> Modal Dialog
    • & In the Templates section, click Application Parts and click Dialog
Dialog
  • To create the dialog box yourself, start a form in Design View. To convert an existing form into a dialog box, set its b> Border Style property value to Dialog. This reduces the system buttons to the Close button only
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

     
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


EmoticonEmoticon

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:o
:>)
(o)
:p
:-?
(p)
:-s
8-)
:-t
:-b
b-(
(y)
x-)
(h)