The Form View

Introduction

Microsoft Access supports various types of views for forms (and reports). One of them, the most regularly used as we have seen so far, shows one record at a time. This is referred to as the Form View or the Single Form.

To create a form view:

If the form exists already or if you are designing the form, in the Property Sheet of the form, click Format and set the Default View to Single Form:

Default View

Practical Learning: Introducing Form Views

  1. Start Microsoft Access
  2. Click Blank Desktop Database
  3. Set the file name to Metro System1
  4. Click Create
  5. Leave the default table without closing it.
    On the Ribbon, click Create
  6. In the Tables section, click Table Design
  7. Create the fields as follows:
     
    Field Name Field Size Caption
    MetroLine 10 Metro Line
    Summary    
  8. In the top section of the window, right-click MetroLine and click Primary Key
  9. Right-click the table's tab and click Datasheet View
  10. When asked whether you want to save the table now, click Yes
  11. Set the table name to MetroLines and press Enter
  12. Create a few records as follows:
     
    MetroLine Summary
    Red Connects Shady Grove to Glenmont, goes through DC, intersects with Orange, Blue, Green, Yellow and Silver Lines.
    Green Connects Greenbelt to Branch Ave, goes through DC, intersects with Orange, Blue, and Silver Lines, tracks with Yellow Line.
    Blue Connects Franconia-Springfield to Largo Town Center, on one part shares tracks with Yellow Line, on another part shares tracks with Orange and Silver Lines.
    Yellow Connects Fort Totten to Huntington, on one part shares  tracks with Yellow Line, on another part shares tracks with Blue Line.
    Orange Runs from Vienna to New Carollton, through DC, intersects with Green and Yellow lines, shares tracks with Blue and Silver lines.
  13. Close the table
  14. On the default table, double-click ID to edit it
  15. Type StationID and press Enter
  16. Right-click the table's tab and click Design View
  17. Set the table name to MetroStations and press Enter
  18. Complete the table as follows:
     
    Field Name Data Type Field Size Caption
    StationID (Primary Key)     Station ID
    StationNumber Number   Station #
    StationName   50 Station Name
    MetroLine   10 Metro Line
    Location      
  19. Right-click the table's tab and click Datasheet View
  20. When asked whether you want to save the table now, click Yes
  21. Create a few records as follows:
     
    Station # Station Name Metro Line Location
    2014 Shady Grove Red Rockville, MD
    1862 Greenbelt Green Greenbelt, MD
    1862 Greenbelt Yellow Greenbelt, MD
    1660 Rockville Red Rockville, MD
    7940 Vienna/Fairfax-GMU Orange Fairfax, VA
    3940 College Park-U of MD Green College Park, MD
    2747 Largo Town Center Blue Largo, MD
    9722 Twinbrook Red Rockville, MD
    3940 College Park-U of MD Yellow College Park, MD
    9283 Prince George's Plaza Green Hyattsville, MD
    2938 Morgan Boulevard Blue Landover, MD
    9571 Dunn Loring-Merrifield Orange Vienna, VA
  22. Close the table
  23. On the Ribbon, click Create
  24. In the Forms section, click Form Design
  25. Double-click the button at the intersection of the rulers
  26. In the Property Sheet, click Data and click Record Source
  27. In the Record Source, select MetroLines
  28. Save the form as MetroLines
  29. In the Tools section of the Ribbon, click Add Existing Fields
  30. In the Field List, double-click LineName
  31. Double-click Summary
  32. Design the form as you see fit. Here is an example:

    Default View

  33. Close the form
  34. When asked whether you want to save, click Yes

Charateristics of a Form View

A form should have a tab or a title bar. If you want to allow the user to select one or more records, the form view should have a record selector, which is controlled by the Record Selectors property.

A form behaves like a wizard, which is a windows made of contiguous pages that follow one another. As we know already, to move from one record to another, the user can click the navigation buttons in the bottom part of the form.

A Form for Data Entry

To create a new record, the user can click the New (Blank) Record button and start typing. Microsoft Access provides an alternative that allows you to present a ready-made form to the for data entry only. The most important characteristics of this form is that its Data Entry field in the Property Sheet must be set to Yes.

To create a form specially made for data entry, start or display a form in Design View. In the Property Sheet, set the following characteristics:

Introduction to the Tabular Form

Overview

A tabular form displays its data in rows, that is, many records in the same view:

Tabular Form

Actually, a tabular form displays its record in a section. Instead of showing one record at a time, the form can show as many records as its size allows. Here is an example:

Continuous Form

This type of form is referred to as continuous because the records are displayed continuously in the same view. If the number of records is not too high, all of them would display. If there are more records than the form's size can allow to view, some records would be hidden. To view them, you can use the scroll bars.

Introduction to Creating a Tabular Form

To create a tabular form:

If the form exists already or if you are designing the form, in the Property Sheet of the form, click Format and set the Default View to Coontinuous Forms

Continuous Forms

Creating a Tabular Form from Juxtaposed Controls

A tabular form has its controls positioned next to each other in their respective sections. This means that they appear like cells of a table. Instead of adding and positioning them manually, Microsoft Access provides faster means. To proceed, select the control. Then, in the Table section of the Arrange tab of the Ribbon, click Tabular Tabular.

To select the controls of a juxtaposed group, click one of them and click the cross cursor on the left. As an alternative, click one of the controls. On the Ribbon, click Arrange and use the buttons in the Rows & Column section.

Practical Learning: Creating a Tabular Form from Juxtaposed Controls

  1. On the Ribbon, click File and click Open
  2. In the list of files, click StatesStatistics1
  3. On the Ribbon, click Create
  4. In the Forms section, click Form Design
  5. Double-click the button at the intersection of the rulers.
    In the Property Sheet, click the All tab
  6. Change the following characteristics:
    Caption: States Statistics - Summary
    Record Source: States
    Default View: Continuous Forms
  7. To save the form, press Ctrl + S
  8. Set the form name as Summary and press Enter
  9. In the Tools section of the Ribbon, click Add Existing Fields
  10. In the Field List, click Abbreviation
  11. Press and hold Shift
  12. Click Capital
  13. Release Shift
  14. Drag the selection to the form

    Selecting Some Fields

  15. On the Ribbon, click Arrange
  16. Make sure all controls are selected on the form.
    In the Table section, click Tabular Tabular

    Tabular Arrangement

  17. In the Form Header section, click the square button and hold your mouse down

    Selecting Fields in a Tabular Form

  18. Drag the selected controls to the left so that the group aligns with the left border of the form

    Selecting Some Fields  

  19. Click an unoccupied area of the form to dismiss the selection
  20. In the Detail section, click and drag Abbreviation up to position it just under the Detail bar

    Selecting Some Fields

  21. Press Ctrl + A to select all controls on the form
  22. In the Table section of the Arrange tab of the Ribbon, click the Remove Layout button Remove Layout
  23. Resize the Detail section to be just enough for the controls on the form
  24. In the Form Footer section, drag the bottom border completely up

    Form Design

  25. Change the caption of the Abbreviation label (you can click it, then click it again to put it into edit mode) to Abbrv
  26. Change the caption of the StateName label to State
  27. Resize the abbreviations label and text box to be just wide enough for the Abbreviation label
  28. Resize the state label and the text box to be enough to accommodate the widest name of a state
  29. On the form,. click the Form Header bar
  30. On the Ribbon, click Home
  31. In the Text Formatting section, click the down-pointing arrow of the Background Color and select Blue, Accent 5, Darker 50% (Theme Colors: 9th column, 6th row)
  32. Click inside the vertical ruler on the left of the Form Header section to select all labels
  33. In the Home tab of the Ribbon, click the arrow of the Font combo box and select Century (if you don't have that font, select Times New Roman)
  34. Click the arrow of the Font Size combo box and select 12
  35. Click the arrow of the Font Color button and select Blue, Accent 1, Lighter 80% (Theme Colors: 5th column, 2nd row)

    Tabular Form

  36. Click inside the vertical ruler on the left of the Detail section to select all text boxes
  37. On the Ribbon, click Format
  38. Click the arrow of the Font combo box and select Century (if you don't have that font, select Times New Roman)
  39. In the Control Formatting section, click the arrow of the Shape Fill button and click Transparent
  40. In the Control Formatting section, click the arrow of the Shape Outline button and click Transparent:

    Tabular Form

  41. Click the Detail bar
  42. In the Font section of the Format tab of the Ribbon, click the arrow of the Background Color and select Blue, Accent1, Lighter 40% (Theme Colors: 5th column, 4th row)

    Tabular Form

  43. Save the form

Characteristics of a Tabular Form

Introduction

A tabular form has some characteristics that set it apart from the Form View. For example, a tabular form should (must) have a form header and a Detail section. It can also have a form footer section. When desining the form, you should (must) put the labels of the controls in the form header.

The Record Selectors

On a tabular 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:

Record Selector

The Alternate Color

An alternate color is one that displays in every other record. For example, if you create a tabular form or report, you can make all rows show their backgrounds in the same color. Here is an example:

Alternate Background Color

To make even rows show their background in one color and odd rows show their background in another color, first set the background color as seen in the previous section. For the alternate color, display the form or report in Design View. On the Ribbon, click Format:

Alternate Row Color

Alternate Row Color

Alternate Row Color

Here is an example:

Alternate Background Color

Practical Learning: Setting the Alternate Color

  1. On the form, click the Detail bar if necessary.
    In the Font section of the Format tab of the Ribbon, click the arrow of the Alternate Row Color button and select Blue, Accent1, Lighter 80% (Theme Colors: 5th column, 2nd row)
  2. To preview the form, on the right side of the status bar, click the Form View button Form View:

    Navigation Buttons

  3. Save the form
  4. After viewing the form, on the right side of the status bar, click the Design View button Design View

The Navigation Buttons

Remember that all records of a tabular form displayin the same view. For this reason, when desigging the form, you should set its Navigation Buttons to No.The lower left section of a form displays the same navigation buttons as the table: the First Record button , the Previous Record button , the Current Record text box , the Next Record button , the Last Record button , and the New (Blank) Record button

Unlike the table, the form does not require the navigation buttons. To let you display or hide the navigation buttons, the Property Sheet of the form is equipped with the Navigation Buttons property.

Practical Learning: Hiding the Navigation Buttons of a Form

  1. Double-click the button at hte intersection of the rulers.
    In the Property Sheet, click the Format tab
  2. In the Property Sheet, double-click Navigation Buttons to set its value to No
  3. To preview the form, right-click the Central tab and click the Form View button Form View

    Navigation Buttons

  4. Close the form
  5. When asked whether to save the changes, click Yes
  6. On the Ribbon, click File and click Open
  7. In the list of files, click FunDS1 from the previous lesson
  8. On the Ribbon, click Create
  9. In the Forms section, click Form Design
  10. Right-click the form and click Form Header/Footer
  11. Double-click the button at the intersection of the rulers.
    In the Property Sheet, click the All tab and change the following properties:
    Record Source: StoreItems
    Caption: Fun Department Store - Store Items
    Default View: Continuous Forms
    Navigation Buttons: No
  12. Save the form as StoreItems
  13. In the Tools section of the Ribbon, click Add Existing Fields
  14. In the Field List, double-click ItemNumber, Manufacturer, Category, SubCategory, ItemName, and ItemSize
  15. On the form, right-click the left ItemSize (the label) and click Cut
  16. Right anywhere in the Form Header section and click Paste
  17. Move the label to the right side to make room
  18. In the same way, cut the other labels from the Detail section, paste them in the Form Header section
  19. Design the form as follows:

    Selecting Some Fields

  20. To preview the form, right-click its title bar and click Form View
  21. Create the following records:
     
    Item # Manufacturer Category Sub-Category Item Name Item Size
    290699 Ralph Lauren Women Shoes Whip Snake Print Perfect 6.5
    379367 Calvin Klein Men Shoes Hervey Square-Toe Leather 11
    746827   Women   Oyster Long Satin Nightgo  
    388729 AK Anne Klein Women Shoes Claw Buckle-Detail Wedge 1
    668156 Ralph Lauren Girls Dresses Girls 2-6x Casey Cotton T 4/4T
    345500 Calvin Klein Women Skirts Petite Crossing Paths Pri 12
    430669 Kenneth Cole New York Women Jewelry Goldtone Beaded Double-Dr  
    426643 Calvin Klein Men Accessories Knit Scarf  
    136843 AK Anne Klein Women Watches Ladies White Ceramic Crys  
    366154 Coach Girls Dresses Girls 2-6X Cotton Tiered 6X
    735312 Cole Haan Women Watches Ladies Black Python-Embos  
    388663 Lauren by Ralph Lauren Women Belts Braided Leather Belt Medium
    441180 Ralph Lauren Girls Shirts Girls 2-6X Short-Sleeved 3/3T
    211771 Ralph Lauren Women Dresses Petite Knit Tweed Short S 12
    545127 Calvin Klein Men Shoes Suede Desert Boots 9.5
    239679 Lauren by Ralph Lauren Women Dresses Sleeveless Shimmer Dress 6
  22. Close the form
  23. When asked whether you want to save the form, click Yes

Datasheet Forms

Introduction

A datasheet form displays exactly like a table. To create a datasheet form:

You can also display any form in Datasheet View. To do this:

On a datasheet form, the record selector is the same as for a table in datasheet view.

Characteristics of a Datasheet Form

A datasheet form is primarily designed like a Form View. This means that during designs, you can include the form header and the footer sections. You can then add the controls as you see fit. When the form displays, only the controls of the Detail section will display. This is not an anomaly but made by design. For example, you can add controls in the form footer section so that those control would hold values that you are aware of and can use in your expressions but the user doesn't need to see such values or controls.

A Split Form

A split form is made of two sections:

Split Form

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 Property Sheet of the form, set its Record Source to the table that holds the value andset its Default Value to Split Form. If it is a brand new form without some previously created fields, use the Field List to add the desired fields to it.

Sub-Forms (and Sub-Reports)

Introduction

A sub-form (or a sub-report) is a form (or a report) that is position on the body of another form (or another report). In order to "include" one form (or report) into another form (or report), both objects must have a relationship. The form (or report) that is hosting the other form (or the other report) is the parent and has (or must have) a primary key. The form (or report) that is added to the parent is called the child form (or child report) and must have a foreign that will communicate with the primary key of the parent table.

Microsoft Access Automatic Sub-Forms

Microsoft Access provides various techniques you can use to create a sub-form. The simplest technique consists of using a wizard. To generate a form that contains a sub-form, start the Form Wizard. In the first page of the wizard, in the Tables/Queries combo box, select the parent object and, in the Available Fields list, select the fields you want to display on the form. Then, in the Tables/Queries combo box again, select the child list. In the Available Fields list, select the fields that the sub-form should display. Continue with the wizard. In the second page, you must be able to identify the relationship that will control the link between both lists. In other words, you must be able to identify the primary key from the parent table and the foreign key from the child table. Once this is clear, you can continue. In the third page of the wizard, you will decide how you want the subform to display, as a tabular list or as a datasheet. After making this decision, you can continue.

Practical Learning: Automatically Creating an Auto-Subform

  1. On the Ribbon, click File and click Open
  2. In the list of files, click VideoCollection1
  3. On the Ribbon, click Create
  4. In the Forms section, click Form Wizard
  5. In the Tables/Queries combo box, select Table: Directors
  6. In the Available Fields list box, double-click Director

    Form Wizard

  7. In the Tables/Queries combo box, select Table: Videos
  8. In the Available Fields list box, double-click the following fields to select them: Title, CopyrightYear, Length, and Rating

    Form Wizard

  9. Click Next
  10. In the second page, make sure by Directors is selected (if not, click it)

    Form Wizard

    Click Next
  11. In the 3rd page, click the Tabular radio button

  12. Click Next
  13. In the 4th page of the wizard, accept the name of the (main) form as Directors.
    Change the name of the subform to sfVideos

    Form Wizard

  14. Click Finish

    Sub-Forms

  15. After viewing the form, close it

Sub-Forms and Sub-Report Design

The alternative to the Form Wizard is to design your own sub-form or sub-report. You have various options:

A sub-form can be created as a tabular form. To use a tabular form as sub-form, its record source must include a foreign key that corresponds to the primary key of the record source of the hosting form.

Practical Learning: Creating and Using a Sub-Form

  1. On the Ribbon, click File and click Open
  2. In the list of files, click Metro System1
  3. On the Ribbon, click Database Tools
  4. In the Relationships section, click the Relationships button Relationships
  5. In the Show Table dialog box, double-click MetroLines
  6. Double-click MetroStations
  7. Close the Show Table dialog box
  8. Drag MetroLine from MetroLines and drop it on MetroLine in MetroStations
  9. In the Edit Relationships dialog box, make sure MetroLine is selected in both combo boxes and click Create

    Relationships

  10. Close the Relationships window
  11. When asked whether you want to save the changes, click Yes
  12. On the Ribbon, click File and click Open
  13. In the list of files, click Ceil Inn1 from the previous lesson
  14. On the Ribbon, click Create
  15. In the Forms section, click Form Design
  16. Right-click the form and click Form Header/Footer
  17. Double-click the button at the intersection of the rulers
  18. In the Property Sheet for the form, click the All tab and change the following properties:
    Record Source: Occupancies
    Default View: Continuous Forms
    Width: 6.5
    Navigation Buttons: No
  19. Save the form as sfOccupancies
  20. In the Tools section of the Ribbon, click Add Existing Fields Field List
  21. In the Field List, double-click DateOccupied, RoomNumber, RateApplied, and PhoneUse
  22. Click an unoccupied area of the form to dismiss the selection
  23. On the form, right-click the left Location (the label) and click Cut
  24. Right-click the area under Form Header and click Paste
  25. Move the label to the right side
  26. In the same way, move the labels from the Detail section to the Form Header section
  27. Position the labels so you can see them and complete the design of the sub-form as you like. Here is an example:

    Sub-Form

  28. Close the form
  29. When asked whether you want to save the changes, click Yes
  30. In the Navigation Pane, right-click the Customers form and click Design View
  31. In the Navigation Pane, drag sfOccupancies and drop it on the form
  32. Complete the design of the form as you see fit. Here is an example:

    Sub-Form

  33. Save and close the sub-form
  34. On the Ribbon, click File and click Open
  35. In the list of files, click FunDS1
  36. On the Ribbon, click Create
  37. In the Forms section, click Form Design
  38. Right-click the form and click Form Header/Footer
  39. Double-click the button at the intersection of the rulers.
    In the Property Sheet, click the All tab and change the following properties:
    Record Source: SoldItems
    Default View: Continuous Forms
    Navigation Buttons: No
  40. Save the form as sfSoldItems
  41. In the Tools section of the Ribbon, click Add Existing Fields
  42. In the Field List, double-click SoldItemID, ItemNumber, ItemName, and ItemSize
  43. On the form, right-click the left ItemSize (the label) and click Cut
  44. Right anywhere in the Form Header section and click Paste
  45. Move the label to the right side
  46. In the same way, cut the other labels from the Detail section, paste them in the Form Header section
  47. Design the form as follows:

    Selecting Some Fields

  48. Close the form
  49. When asked whether you want to save the form, click Yes

A Datasheet as a Sub-Form

A sub-form can be presented as a datasheet, in which case it would display exactly like a table, a series of columns and cells.

Practical Learning: Using a Datasheet as a Sub-Form

  1. On the Ribbon, click File and click Open
  2. In the list of files, click Road System1
  3. On the Ribbon, click Create
  4. In the Forms section, click Form Design
  5. Double-click the button at the intersection of the rulers
  6. In the Property Sheet for the form, click the All tab and change the following properties:
    Record Source: to Intersections
    Default View: Datasheet
    Navigation Buttons: No
  7. Save the form as sfIntersections
  8. In the Tools section of the Ribbon, click Add Existing Fields Field List
  9. In the Field List, double-click Road2
  10. Double-click InNear
  11. On the form, remove 2 from the left Road2 (the label) to display Road
  12. Change the caption of the left InNear (the label) to display In/Near

    Sub-Form

  13. In the Design View of the Ribbon, in the Views section, click the View button
  14. Double-click the right border of the In/Near column to make it fit the widest text
  15. Using the buttons in the Formatting section of the Datasheet tab and the buttons in the Text Formatting section of the Home tab of the Ribbon, design the datasheet as you see fit. Here is an example:

    Sub-Form

  16. Close the datasheet sub-form
  17. When asked whether you want to save the changes, click Yes

Dialog Boxes

Introduction

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

Dialog Box

Creating a Dialog Box

To create the dialog box, start a form in Design View. To convert an existing form into a dialog box, set its Border Style property value to Dialog:

Creating a 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. On the Ribbon, click Create and, in the Forms section, click Form Design
  2. Double-click the button at the intersection of the rulers to access its properties.
    In the Property Sheet, click the Format tab and click Border Style
  3. Click the arrow of the Border Style field and select Dialog
  4. Switch the form to Form View to preview
  5. Switch it back to Design View
  6. To complete the dialog box, in the Format tab of the Property Sheet, change the following properties:
    Auto Center: Yes
    Record Selectors = No
    Navigation Buttons = No

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.

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. 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.

Practical Learning: Creating a Modeless Dialog Box

  1. The dialog box should still be opened in the Design View.
    To make it a modeless dialog box, in the Property Sheet, click the Other tab. Double-click Pop Up to change its value from No to Yes
  2. Close the form
  3. When asked whether you want to save, click No

A Message Box

Introduction

A message box is a smaller and simpler version of a dialog box. It is used to display a piece of information to the user. The message box is equipped with a button the user can click to dismiss the message box.

Creating a Message Box

Unlike a form or a dialog box, a message box is not designed. Instead, to create a message box, you use MsgBox() (in the next lesson, we will see where you can type it. In the parentheses, enter the message you want to display. Obviously the message is provided as t3ext. Therefore it should be included inside double-quotes.

Practical Learning: Ending the Lesson

  1. Close Microsoft Access

Previous Copyright © 2002-2021, FunctionX, Inc. Next