Home

Maintaining Windows Controls

Spacing the Windows Controls

Spacing the Ranges of Controls Vertically

Consider the following form that is being designed:

Control Design: Spacing the Ranges of Controls Vertically

Notice that the controls are logically and vertically aligned. For example, the First Name label, its text box, the Last Name label, and its text box have the same top alignment (distance from the top border of the form). In the same way, the City label, its text box, the State label, and its text box have the same top alignment (distance from the top border of the form). When moving and aligning the controls on a form or report, one of the concerns you may have is that the vertical distance among the controls from one range to the next or from one range to the previous range is not logically sound. Of course, you can move the controls to adjust this. Fortunately, Microsoft Access provides a set of tools you can use to create a better spacing between the ranges of controls. You can first select the controls that have been vertically aligned already. Here is an example:

Control Design: Selection Before Spacing

Then:

The Spacing section of the Ribbon

If you select:

Here is one way you can take advantage of the Vertical buttons of the Position section of the Ribbon:

  1. Position the controls on the form and manually align them on each range as you see necessary. Here is an example:
     
    Control Design: Control Spacing
  2. Select the controls
  3. Use the Decrease Vertical option continually until the controls on each range touch those on the previous range. Here is an example:
     
    Control Spacing: Decrease Vertical
  4. Use the Increase Vertical option continually until you get the distance you want between the ranges. Here is an example:
     
    Increase Vertical
     
    Here is the result in the preview:
     
    Result
     
    Notice that the distances among the ranges of controls are the same

Practical Learning: Spacing the Ranges of Controls Vertically

  1. Start Microsoft Access
  2. Open the Bethesda Car Rental1 database from the previous lesson
  3. In the Navigation Pane, right-click Company Assets and click Design View
  4. Press Ctrl + A to select all controls
  5. On the Ribbon, click Arrange if necessary.
    In the Sizing & Ordering section, click Size/Space and click Decrease Vertical
  6. Again, click Size/Space -> Decrease Vertically continually until the controls from one range touch the controls on the upper range
     
    Decrease Vertical
  7. Click Size/Space -> Increase Vertical twice
     
    Increase Vertical
  8. Save the form
  9. Right-click the title bar of the form and click Form View

Spacing a Stack of Controls Horizontally

Consider the following two sets of controls (buttons) on a form that is being designed:

Form in Design View

Notice a problem of horizontal spacing among the controls of the same range. In the top range, the controls are positioned on top of each other. In the bottom range, the space between the left and the middle buttons is not the same as the space between the middle and the right buttons, although they are clearly in the same range. To solve this type of problem, of course you can move the controls using any of the techniques we have reviewed so far. Alternatively, Microsoft Access provides another set of tools you can use to create a better spacing among the controls of the same range.

Image you want the controls in the top range to rather have their borders touch each other instead of having them positioned one on top of another. To start, you can select them. Here is an example:

form Design

After selecting the controls, on the Ribbon, click Arrange. In the Size & Ordering section, click Size/Spacing and use the Horizontal options in the Spacing section:

Spacing

Imagine the controls were not positioned on top of each other, for example, suppose you want to position the controls of our bottom range. Once again, first select them:

Control Spacing: Control Selection

Then click the Equal horizontal button. In this case, Microsoft Access would get the various distances among the controls (in this case, that would be the distance between the left control and the middle control), and the distance between the middle control and the right one). Then, Microsoft Access would calculate the average of these measures, and would apply it as the new distance mong the controls. The above selection would produce:

Spacing

Once again, consider the following form in design:

Form in Design View

Notice that the controls in the bottom range don't show a good spacing (the distance between two controls). Imagine you want to apply a better spacing among the controls of the same range. First select the controls of the same range. Here is an example:

Control Spacing: Control Selection

If you click:

Here is one way you can take advantage of the horizontal alignment:

  1. Position the controls on the form and align horizontally even if they touch each other or some are positioned on top of others. Here is an example:
     
    Spacing
  2. Select the controls
  3. Click the Decrease Horizontal button continually until the controls touch each other. Here is an example:
     

     
    Spacing
     
    Spacing
     
    If you want the controls to touch each other, which can be cute for buttons, you can stop. Here is a preview from the above:
     
    Spacing
     
    Otherwise, if you want more space among the controls...
  4. Click the Increase Horizontal button continually until you get the distance you want between the control. Here is an example:
     
    Spaging
     
    Here is the result in the preview:
     
    Spacing
     
    Notice that the distances among the controls are the same
     

Stacking or Juxtaposing the Controls

 

Introduction

Microsoft Office Access 2010 brought new tools to align controls during design. Those tools are available in the Arrange tab of the Ribbon. Those tools are available when the form or the report is in Design View. These tools make it easy for Microsoft Access to automatically stack or juxtapose a group of controls.

Stacking Controls Vertically

One of the ways you can align the controls is to stack them; that is, to position controls above each other. Besides the manual techniques we saw already, to stack a group of controls, first select them. Then, on the Ribbon, click Arrange. In the Table section, click Stacked Stacked.

Practical Learning: Stacking Some Controls

  1. On the Ribbon, click Create
  2. In the Forms section, click Form Design
  3. On the Ribbon, click Design if necessary.
    In the Controls section, right-click the Text Box control Text Box and click Drop Multiple Controls
  4. Click the top-center section of the form
  5. Click the left-middle section of the form
  6. Click the bottom-right section of the form
  7. In the Controls section, click the Select button Select
  8. Press Ctrl + A to select all three text boxes
  9. On the Ribbon, click Arrange
  10. In the Table section, click Stacked

Juxtaposing Controls

Besides the techniques we saw to position the controls next to each other, you can treat their positions as cells of a table and align them accordingly. To do this, select the control. Then, in the Table section of the Arrange tab of the Ribbon, click Tabular Tabular.

Practical Learning: Stacking Some Controls

  1. On the Ribbon, click Design if necessary.
    In the Controls section, right-click the Button control Button and click Drop Multiple Controls
  2. Click the left-center section of the form
  3. Click the middle-center section of the form
  4. Click the right-center section of the form
  5. In the Controls section, click the Select button Select
  6. Click one of the newly added button
  7. Press and hold Shift
  8. Click each of the other two buttons on the form
  9. Click Shift
  10. On the Ribbon, click Arrange
  11. In the Table section, click Tabular
  12. To preview the form, right-click its title bar and click Form View
  13. Close the form
  14. When asked whether you want to save, click No

Using Stacked or Juxtaposed Controls

 

Selecting Controls

Before taking any action on a group of stacked or juxtaposed controls, you must first select them. You have three options:

Selecting Controls

Click it.

Using the Grid Lines

If you use the Stacked or the Tabular button to align the controls, Microsoft Access adds some grid lines around the control(s).

By default, those grid lines are invisible but if you want, you can show them. You can even paint them in any color of your choice.

The visibility of the grid lines around the objects is controlled by the Gridlines button:

Gridlines

Before controlling the grid lines, on the form or report, click one of the controls in the group. You should see a gray square with a cross inside. Click it:

Managing Stacked or Tabular Controls

There are many actions you can take on the controls that belong to a stacked or tabular group of control. As you may know already, the controls are considered as a group and must be treated so. To separate them and treat each individually, select the group. In the Table section of the Arrange tab of the Ribbon, click the Remove Layout button Remove Layout.

To delete all controls from the group, after accessing the group:

Adding a Stacked Column

Normally, when you select some controls and click the Stacked button, Microsoft Access uses the number of vertical ranges to decide how many columns to create. If those are not enough, you can add new empty columns. To do this, select the group. On the Ribbon, click Arrange. In the Rows & Columns section:

Adding a Row

When you create a group of controls using the Tabular option, Microsoft Access uses the number of columns to decide how many rows to create. If you want, you can add new empty rows. To do this, select the group. On the Ribbon, click Arrange. In the Rows & Columns section:

Moving Controls Within the Group

If you insert a row inside the group, it would appear empty while the objects on the other row(s) move. You can then move an existing control from its current position to the empty cell above or below. To do this, click the control. On the Ribbon, click Arrange. In the Move section, click either Move Up Move Up or Move down Move Down.

Control Maintenance

 

Copying a Control

If you had applied some design on a control and you want to replicate that design, you can copy the control. This is mostly a simple operation of copy n' paste. You can copy a control on a form (or report) and paste it on the same form (or report) or you can paste it in another form (or report). When you copy and paste a control, there are some characteristics it would retain and some others it would loose. Normally, it would keep its aesthetic characteristics (such as the color) and its size but it will loose some others (such as its location and its programmatic characteristics such as its name (we will learn that two controls cannot have the same name on the same form or report).

To copy a control, first select it and then press Ctrl + C. You can also right-click a control and click Copy.

To control a group of controls, select them and press Ctrl + C. You can also select the controls, right-click one of the selected controls, and click Copy.

To paste a copied control or a copied group of controls from the clipboard, click the destination and press Ctrl + V. You can also right-click the destination and click Paste.

Deleting a Control

If you have added a control or it was created by the Form Wizard or the Report Wizard but you don't need it anymore, you can remove it from the database. You can also delete a group of controls in one step.

To remove a control from a form or a report, click it and press Delete. If you click a text box or a control that is accompanied by a label and delete it, its label is deleted also.

To remove a group of controls, select them and press Delete.

Tab Ordering the Controls

When we introduced data entry for a form, we saw that the user could press Tab to move from one control to another. For example, after the user has entered data in the most left text box of the form, if there is another text box on the right side, when the user presses Tab, the caret should move to that right control. If there is no control on the right side, the caret should move to the control under the one previously used. If the caret or focus is in the last bottom control on the form and the user press Tab, the caret should move to the next record, unless the form is configured to display only one record. This follows the arranged sequence of the controls on the form. For this reason, the controls on a form should be aligned in the order of a logical sequence.

When you add a control to a form that already has other controls, it is sequentially positioned at the end of the existing controls. If you don't fix it, the data entry personnel could have a hard time figuring out how the sequence should be followed.

The sequence of controls navigation is set using the Tab Order dialog box. The Tab Order dialog box is available when the form is opened in Design View. To display it, while the form is in Design View:

This would open the Tab Order dialog box:

Tab Order

The simplest and quickest way to rearrange the order of items is to click the Auto Order button. Sometimes, you will not like the arrangement made by the Tab Order dialog box. To rearrange items manually, you can move a row or a group of rows.

Practical Learning: Sequentially Ordering Controls

  1. The Company Assets form should still be opened in Form View
  2. To test it, click CompanyAssetID
  3. Press Tab
  4. Notice that the caret moves to the Purchase Price text box
  5. To switch the form to the other view, right-click somewhere on its body and click Design View
  6. Right-click an empty area of the form and click Tab Order
  7. Position mouse mouse on the left button of CompanyAssetID until the mouse turns into a right pointing arrow
     
    Tab Order
  8. Click to select the row, and release the mouse
  9. Click and hold your mouse on the same row header
  10. Drag up by two rows and notice the horizontal line that guides you
     
    Tab Order
  11. Release the mouse
  12. Click the Auto Order button
     
    Tab Order
  13. Click OK to acknowledge the order
  14. To preview the form, right-click its tab (the Company Assets tab) and click Form View
  15. To save the form, press Ctrl + S
  16. To close the form, press Ctrl + F4

Lesson Summary

     

Exercises

 

Yugo National Bank

  1. Open the Yugo National Bank1 database
  2. Open the TransactionTypes table create the following records:
     
    TransactionType
    Deposit
    Withdrawal
    Fund Transfer
    Money Order
    Service Charge
  3. Close the table

Watts A Loan

  1. Open the Watts A Loan database
  2. Using the Table button in the Create section of the Ribbon, start a a table. After the ID column, using the Add New Field, create the following columns: LoanType and Description.
  3. Rename the first column from ID to LoanTypeID
  4. Save the table as Types of Loans and close it

Using Senate

  1. Create a blank database named US Senate1
  2. Close the default table without saving it
   
 

Previous Copyright © 2000-2016, FunctionX Next