Lessons Logo

Sectional and Tabbed Forms

 

Sectional Forms

 

Introduction to Form Breaks

Many databases are made of various objects and it is not unusual for one of these objects to contain various fields. If you try to create a form for such an object, you may encounter a big real estate deficiency. Even if you decide to reduce the amount of information on a table, because you still need to follow your customer’s goal, you may not have this complete liberty. Therefore, instead of deleting necessary fields, you can one of the various alternatives offered by Microsoft Access.

When logistic becomes a problem for the amount of information you need to include in a form, you can divide the form into sections and allow the user to access only one section at a time, although still remaining in the same form. This is made possible by a special control called the Page Break.

 

Page Breaks

To create sections on a form, on the Toolbox, click the Page Break control and click on the left side inside the Detail section of a form. You can add as many sections as you want. To make the roles of your form sections efficient, they should have the same height. Otherwise, when you decide to display them, part of one section might appear in another section, which would deceive the purpose of creating sections.

Practical Learning: Dividing a Form in Sections

  1. Open the Bethesda Car Rental1 database and, from the Forms section, double-click the Customers2 form to open it
  2. After viewing the form, switch it to Design View
  3. On the Toolbox, click the Page Break button and, on the form, click in the Detail section at 21/4 of the vertical ruler
     
  4. From the Toolbox, click the Page Break button and, on the form, click in the Detail section at 4.5 of the vertical ruler
     
  5. Save and close the form

Tabbed Forms

Introduction

Besides the page breaks you can use to divide a form, if you are designing a form for a long list of fields, you can group them in tabs. A tab control is an object that is used to hold other Windows controls. This control presents a tab button on its top section. This tab button should present a label that indicates what the tab is used for. Sometimes, a tab is also called a property page.

The primary job of a tab control is to “hold”, “host”, or “carry” other controls. It can appear by itself. Here is an example:


In most cases, a tab control comes in a group with one or more others. In this case, each tab hosts or carries its own controls. Tabs are arranged in a 3-dimensional coordinate where the Z-axis moves from the computer screen towards you. In this scenario, tabs are positioned one in front of the other(s).

To use a tab control, the user clicks a tab. The tab that was clicked comes in front and displays its “children”. The other tab(s) goes(go) to the back and hides(hide) its(their) child(ren). If there is more than one tab, all tabs display a labeled button on top. To change the list, the user simply clicks another tab and the scenario renews. Here is an example:

To create a tabbed form, while in Design View, on the Toolbox, click the Tab Control button and click the form

Practical Learning: Creating a Tabbed Form

  1. The Bethesda Car Rental1 database should still be opened.
    From the Forms section, double-click the Customers1 form to open it
  2. After viewing the form, switch it to Design View
  3. On the Toolbox, click the Tab Control button and click somewhere in the top-left part of the Detail section
     
  4. Save and preview the form
  5. Switch it back to Design View

Characteristics of a Tab Control

By default, after adding a new tab control to a form, it is equipped with two property pages. Before manipulating a tab control, there are details you should keep in mind. In the programming world, we consider that a tab control is actually made of two objects presented as one. A tab sheet, also called a property sheet is like the desk of a table. If you listened to your teacher in primary or elementary school, you probably heard her saying over and over that you should/must not write on the desk of a table. This is also true here. In real life, every on a table is positioned on that table, like pieces of paper. On a tab sheet, the tab controls, also called property pages, are positioned on the tab sheet (in Microsoft Access, you cannot access the tab sheet, meaning you cannot place anything on it; in some programming environments, like Microsoft Visual C++, you can certainly access the property sheet). This discussion is intended to show you that there is a separation between the tab control and the area on which it lies. This makes it possible to move all tab controls with one movement.

The tab sheet is a rectangle that surrounds the tab controls and holds them as their parent. To tab sheet is represented by the area on the right side of the tabs. To select that tab sheet, you can click that area:

When the tab sheet is selected, you can see that its Name in the Properties window starts with TabCtlX. If you select the tab sheet and move it, the tab controls, also called property pages, on it would move also. If you delete the tab sheet, its property pages would be deleted also. For this reason, the tab sheet is considered their parent.

As mentioned already, the tab controls you use are actually positioned on a tab sheet. Each tab control or property page is considered on its own and its only relationship with the other tabs is that they belong to the same sheet. Based on this, each tab can be accessed separately. To manipulate the properties of a tab page, you should select it first. To do that, click its label (not necessarily its body).

By default, after adding a new tab control to a form, it is equipped with two tab pages. To add a new tab, you can right-click one of the tabs or the area of the tab sheet and click Insert Page. To remove a tab page, you can click its tab and press Delete. Alternatively, you can right-click a tab and click Delete Page. 

We stated that a tab control (property page) acts as a parent for other controls positioned on it. Based on its role, it should indicate its role. This is specified by its button, which displays a caption. Therefore, after adding a tab control, one of the first actions you probably should take is to specify its role. This is role by changing the value of its Caption in the Properties window.

After you have typed a string for the Caption of a tab, its width is adjusted to accommodate its string. This is done for each tab. Consequently, one tab with a Resume Caption and another tab with Personal Information, as Caption, would have different widths. Alternatively, you can give the same width to all tabs regardless of their different lengths of strings. In this case, a tab with Resume and another with Personal Information labels would have the same width. To give the same width to the tabs, in the Format tab of the Properties window of the tab control (the property sheet itself), change the value of the Tab Fixed Width. The default value of 0” means that you let Microsoft Access determines the necessary width to contain the label on the tab. You can then change the value as you wish. In the same way, the Tab Fixed Height can be used to control the height of the tabs or buttons.

You can display either or both a picture and a label on the tab. Although picture can be any size, you should limit it to 16x16 pixels. To add a picture to the button, select the tab. In the Properties window, click the Picture property and click its ellipsis button. Locate and select a picture. It should be a bitmap (with bmp extension) or an icon (with ico extension).

By default, property pages display their labels on a tab. If you do not like the tab, you can use either a button or nothing. This property is called by the Style field in the Properties window of the tab sheet. Like the Tabs value, the Buttons property allows each property page to display a label that indicates its role. If you set the Style property to None, the property sheet would appear as a simple rectangular box and the user would not be able to change the pages. Therefore, if you decide to use this option, unless you want to hide the other pages, make sure you provide the user with the means of switching to a difference property page.

Based on the role of the tab sheet, some properties of the tab sheet are also imposed on the tab pages. For example, on the Properties window, if you change the value of the Top or the Left properties, the tab sheet moves and at the same time, the corresponding values of the tab pages are changed.

Practical Learning: Configuring Tab Controls

  1. The Bethesda Car Rental1 database should still be opened with the Customers1 form in Design View.
    Click the empty gray section on the right side of the right Page tab to select the tab sheet and hold the mouse down
  2. Drag it in the left direction
  3. To add a new property page, right-click one of the Page buttons and click Insert Page
  4. Double-click the most-left Page button. In the Properties window, click the Format property page and click Caption
  5. Type Contact and press Enter
  6. Click the middle Page button. In the Properties window, change the Caption to Driver’s License
  7. Click the most-right Page button. In the Properties window, change the Caption to Notes/Comments
     
  8. Save and preview the form
  9. After viewing it, switch it back to Design View
  10. To add bitmaps to tabs, you will first design one.
    Start Microsoft WordPad (Start -> (All) Programs -> Accessories -> WordPad. On the Formatting toolbar, change the Font to Wingdings. Change the Font Size to 12. Type + (which is Shift and +) to produce an envelope. Select the character. Press Ctrl + C to copy it. Start Microsoft Paint (Start -> (All) Programs -> Accessories -> Paint. With the new empty document, press Ctrl + V to paste. As the picture is still selected with a dotted rectangle around it, click it and hold the mouse down. Then drag left until its left border touches the left border of the frame. To enlarge the picture, on the Tool Box, click the Magnifier button. To reduce the size of the picture, on the main menu, click Image -> Attributes… In the Attributes dialog box, change the Width and the Height to 16 each. Using the tools in the Tool Box and the colors in the Color Box, design the picture as follows:
     


    To save the picture, on the main menu of Paint, click File -> Save. Save it as contact in your Exercises folder. Make sure you keep the default bmp extension.

  11. To use a bitmap on a tab, on the form in Design View, double-click the Notes/Comments tab
  12. In the Properties window, click Picture and click its ellipsis button. In the Picture Builder dialog box, scroll down in the Available Pictures list box and click Compile Modules
     
  13. Click OK
  14. On the form, click the Contact tab. In the Properties window, click the Picture field and click its ellipsis button
  15. In the Picture Builder dialog box, click the Browse button. Locate your Exercises folder and display it in the Look In combo box
  16. Select contact and click Open
  17. In the Picture Builder dialog box, click OK
  18. Save and preview the form
     
  19. Switch the form back to Design View
  20. To add a control to the form, on the form, click the Contact tab. From the Field List, drag FirstName and drop it under the Contact tab
  21. On the form, click the Driver’s License tab. On the Field List, click and drag DateIssued to the form
  22. Save and preview the form
     
  23. Close the form
  24. Open the Music Collection2 database and click Forms
  25. Double-click the MusicAlbums form to open it
  26. After viewing it, switch it to Design View
  27. On the right side, double-click the empty area on the right side of the Comments tab to select the property sheet
  28. In the Properties window, click the Format tab. Click Tab Fixed Width. Type .98 and press Enter
  29. Save and preview the form
     
  30. Close the Music Collection – Albums form
 

Previous Copyright © 2007 Yevol Next