Home

Details on Controls Design

 

The Location of a Control on a Form or a Report

 

The Top and Left Properties of a Control

When you add a control to a form or report, it takes a position on its host but it depends on the control. The location of a control is both:

  • The distance between the top border of the form or report, and the top border of the control
  • The distance from the left border of the form or report to the left border of the control

In the Properties window, the distance between the top border of the form or report and the top border of the control is represented by the Top property. The distance between the left border of the form or report and the left border of the control is represented by the Left property:

 

Moving Controls Randomly

After adding a control to a form or report, it assumes a position based on where you clicked but this may depend on the control. Most of the time, you will want to change the position. Moving a control consists of changing its location on the form or the report. There are various ways you can do this.

You can move a control along the grid lines or you can ignore them:

  • To move a control along the grid lines, on the Ribbon, click Arrange and, in the Control Layout section, click the Snap to Grid button to set it on Snap to Grid, then click the control and immediately drag left, right, up or down. When you get to the desired location, release the mouse
  • To move a control without following the grid line, on the Ribbon, click Arrange and, in the Control Layout section, click the Snap to Grid button to unset it Snap to Grid, click and immediately drag the control left, right, up or down. When you get to the desired location, release the mouse

To move a control or a group of controls with even more precision, in the Properties window, you can change either or both the Left and the Top values.

Practical Learning: Moving Controls Randomly

  1. Start Microsoft Access and, from the resources that accompany these lessons, open the Bethesda Car Rental1 database
  2. In the Navigation Pane, right-click the All Tables bar, position the mouse on Category, and click Object Type
  3. In the Forms section of the Navigation Pane, right-click the Company Assets form and click Design View
  4. On the ribbon, click Arrange and make sure the Snap to Grid button is clicked Snap to Grid. Otherwise, click it

Moving Controls Vertically

 

Introduction

When a control has been selected, as your mouse moves over it, its pointer displays a different cursor. One of these cursors can be used to move a control. This cursor is represented as a cross with four arrows:

By default, when dragging the control(s), it(they) move(s) by one unit of the grid lines on the form or report and you can move left, right, up, or down but:

  • If you want to move one control vertically one unit of grid lines at a time, click the control and press the down or the up arrow keys a few times until you get the distance you want
  • If you want to move a group of controls vertically one unit of grid lines at a time, select the controls and press the down or the up arrow keys a few times until you get the distance you want
  • If you want to move one control vertically one unit of grid lines at a time, first deselect the controls (make sure no control is selected), press and hold Shift, then click the control and immediately drag the mouse up or down. When you get to the desired location, release the mouse and release Shift
  • If you want to move many controls vertically one unit of grid lines at a time, first deselect the controls (make sure no control is selected), press and hold Shift, click each control except the last (for example if you want to move four controls vertically, press and hold Shift, then click the first three). When you get to the last control of the group (for example the 4th), click it and immediately drag (don't release after clicking) the mouse up or down. When you get to the desired location, release the mouse and release Shift
  • If you want to move one control vertically without following the grid lines, first deselect the control(s) (make sure no control is selected). Press and hold Ctrl + Shift. Click and immediately drag the control up or down. When you get to the desired location, release the mouse and Ctrl
  • If you want to move many controls vertically without following the grid lines, first deselect the control(s) (make sure no control is selected). Press and hold Ctrl + Shift. Click each control except the last to select them. When you get to the last control of the desired group, click and immediately drag up or down. When you get to the desired location, release the mouse, the Shift and the Ctrl keys

You can also move the controls vertically using the Properties window:

  • To move one control, change the value of its Top field
  • To move many controls, first select them. Then, in the Properties window, change the value of the Top field

Practical Learning: Moving Controls Vertically

  1. Click the CompanyAssetID label on the form
  2. Position the mouse on the upper left corner of the selected label until the cross cursor appears:
     
  3. Click and drag up and left to move the label so that its left border aligns with the 1/4 measure of the horizontal ruler and its top border aligns with the 1/8 measure of the vertical ruler:
     
     
  4. Release the mouse
  5. Save the form

Aligning Controls Vertically

Consider the following form:

Form Design: Control Alignment

One of the obvious problems is that this layout does not follow any reasonable logic. Among the remedies to this, you can better align the controls. For example, you may want the First Name label, the top Unbound text box, the MI label and its text box to have the same distance from the top border of the form. Aligning the controls consists of using a reference to position other controls based on this reference. Fortunately, Microsoft Access provides all the necessary tools to align the controls on a form or report.

To assist you with aligning the controls on a form or a report, the ribbon provides the Control Alignment section. To access it, while the form or report is in Design View, on the ribbon, click Arrange and you will see the section labeled Control Alignment:

Before aligning some controls you must first decide which one would be used as a reference. This means that you can use the alignment of one control as a reference for the other controls. To do this, position that control as the others should be aligned vertically. For example, imagine that, from the above form, you want to position the First Name label, its text box, the MI label, and its text box to have the same distance from the top border of the form. You can start by positioning one of these control at the top distance you want. Here is an example:

Form Design: Positioning a Control Whose Top Alignment Would be Used as a Reference

After doing this, the alignment of such a control, in this case the top alignment of the First Name label, can be used to align the First Name text box, the MI label, and the MI text box. To align the other controls, first select them. Here is an example:

Form Design: Controls Selection

To align the controls, in the Control Alignment section of the Arrange group of the ribbon, you can click the Top button . You can also right-click one of the selected controls, position the mouse on Align, and click Top. Here is the result from the above selection:

In the same way, you can align other controls. You can also align controls to the bottom: first align the one that would be used as the reference, select the others, and click the Bottom button in the Control Alignment section of the ribbon. You can also right-click one of the controls in the selection, position the mouse on Align, and click Bottom.

Practical Learning: Aligning Controls Vertically

  1. On the form, click the CompanyAssetID label to select it
  2. Press and hold Shift
  3. Click the CompanyAsset text box to have the label and the text box selected
     
  4. On the ribbon, click Arrange and, in the Control alignment section, click Top
  5. Save the form

Moving Controls Horizontally

 

Introduction

Instead of moving the control(s) randomly or vertically, you can move it(them) horizontally only:

  • If you want to move one control horizontally one unit of grid lines at a time, click the control and press the right or left arrow keys a few times until you get the distance you want
  • If you want to move a group of controls horizontally one unit of grid lines at a time, select the controls and press the right or the left arrow keys a few times until you get the distance you want
  • If you want to move one control horizontally one unit of the grid lines at a time, first deselect the controls (make sure no control is selected), press and hold Shift, then click the control and immediately drag the mouse left or right. When you get to the desired location, release the mouse and release Shift
  • If you want to move many controls horizontally one unit of grid lines at a time, first deselect the controls (make sure no control is selected), press and hold Shift, click each control except the last of the desired group. Click the last control and immediately drag the mouse left or right. When you get to the desired location, release the mouse and release Shift
  • If you want to move one control only horizontally without following the grid lines, first deselect the control(s) (make sure no control is selected), press and hold Ctrl + Shift. Click and immediately drag the mouse left or right. When you get to the desired location, release the mouse, the Shift and the Ctrl keys
  • If you want to move many controls only horizontally without following the grid lines, first deselect the control(s) (make sure no control is selected). Press and hold Ctrl + Shift. Click each control except the last to select them. When you get to the last control of the desired group, click and immediately drag left or right. When you get to the desired location, release the mouse, the Shift and the Ctrl keys

You can also move the controls horizontally using the Properties window:

  • To move one control, change the value of its Left field
  • To move many controls, first select them. Then, in the Properties window, change the value of the Left field

Practical Learning: Moving Controls Horizontally

  1. On the form, click the Date Acquired text box
  2. Press and hold Shift
  3. Click the following text boxes: Category, Make, Model, and Purchase Price
  4. Release Shift
  5. Press the right arrow key 20 times
  6. Save the form

Aligning Controls Horizontally

Imagine you want to position some labels of the above form to the left. You can start by positioning the First Name label to the desired left distance:

Form Design: Positioning a Control Whose Alignment Would be Used as a Reference

After doing this, the alignment of such a control, in this case the First Name label, can be used as a reference for the others. To align the other controls, first select them. Here is an example:

Notice that only the controls that will be aligned, in this case only some labels, have been selected. To align them, in the Control Alignment section of the Arrange group of the ribbon, you can click Left Left. Alternatively, you can right-click one of the controls in the selection, position the mouse on Align, and click Left. Here is the result from the above selection:

Control Alignment

In the same way, you can align other controls. You can also align controls to the right: first align the one that would be used as the reference, select the others, and click the Right button in the Control Alignment section of the ribbon.

Practical Learning: Aligning Controls Horizontally

  1. On the form, click the CompanyAssetID label
  2. Press and hold Shift
  3. Click the following labels: Date Acquired, Category, Make, Model, and Purchase Price
  4. On the ribbon, click Arrange if necessary. In the Control Alignment section, click Left
     
  5. On the form, click the CompanyAsset text box
  6. Press and hold Shift
  7. Click the following text boxes: Date Acquired, Category, Make, Model, and Purchase Price
  8. Right Make (or one of the selected controls), position the mouse on Align, and click Left
     
  9. Click the button at the intersection of the rulers
  10. Save the form

The Size of a Control

 

Introduction

The size of a control is both:

  • The distance from its left to its right borders: its width
  • The distance of its top to its bottom borders: its height

When you add a control to a form or report, it assumes a certain size depending on the type of control. In some cases, you will want to change the size the a control. Resizing a control consists of changing its measures. There are various ways you can do this.

Resizing a Control

Resizing a control consists of changing either its width, its height, or both. Before resizing a control, first select it. To resize a selected control, position the mouse on one of its borders. When the mouse moves over a selected control and reaches one of the handles, the mouse pointer displays a double-arrow cursor. The possible mouse pointers are:

Cursor Role
Shrinks or heightens the control
Resizes the control in North-East <-> South-West direction
Narrows or widens the control
Resizes the control in North-West <-> South-East direction

Although these pointers can be used to resize one control, they can also be applied to a group of controls. Based on this:

  • To resize a control along the grid lines, select it first. Position the mouse on one of the handles to seize the cursor of your choice. Click and drag in the desired and appropriate direction
  • To resize a control without following the grid lines, select it first. Press and hold Ctrl. Position the mouse on one of the handles to seize the cursor of your choice. Click and drag in the desired and appropriate direction

Practical Learning: Resizing a Control

  1. On the form, click the CompanyAsset text box
  2. Position the mouse on the middle handle of its right border
     
  3. Click and drag left until the right border of the text box aligns with the 2 measure of the horizontal ruler
     
  4. Release the mouse
     
  5. Save the form

Resizing Various Controls

Instead of one, you can also resize a group of controls at the same time:

  • To resize more than one control along the grid lines, select them. Position the mouse on one of the handles of the selected controls to get the desired cursor. Click and drag appropriately. all of the selected controls would be resized
  • To resize more than one control without following the grid lines, select them first. Press and hold Ctrl. Position the mouse on one of the handles of the selected controls to get the desired cursor. Click and drag appropriately. all of the selected controls would be resized

To further assist you with resizing a control, Microsoft Access provides the Size section of the ribbon. To access it, while the form or report is in Design View, click Arrange. To resize a group of controls, first select one and set the desired size, such as the desired width. Consider the following form:

Imagine you would like the First Name text box, the Last Name text box, and the Gender combo box to have the same dimensions. First select the controls that will be resized:

To resize the controls, on the ribbon, click Arrange and select in the Size section. Alternatively, you can click one of the selected controls, position the mouse on Size, and select one of the options:

Ribbon Button Name Shortcut Menu Description
Size to Fit To Fit The controls will be resized based on the contents of their value
Size to Grid To Grid The controls will be resized so their borders fit with the grid lines
Size to Tallest To Tallest The heights of the selected controls will be increased to match the height of the tallest control
Size to Widest To Widest The widths of the selected controls will be increased to match the width of the widest control
Size to Shortest To Shortest The heights of the selected controls will be decreased to match the height of the shortest control
Size to Narrowest To Narrowest The widths of the selected controls will be decreased to match the width of the narrowest control
 

Practical Learning:  Resizing Various Controls

  1. On the form, position the mouse inside the horizontal ruler at 1/2 and click to select the labels
  2. On the ribbon, click Arrange if necessary and, in the Size section, click To Widest
     
  3. Save the form

The Width and the Height Properties of a Control

You can also resize a control or a group of controls using the Properties window. In the Properties window, the width of a control is represented by the Width property while the height of a control is represented by the Height field. Therefore, to resize a control with more precision, you can change either or both its Width and/or its Height properties. To resize a group of controls, first select them. In the Properties window, change either or both the values of the Width and/or the Height fields.

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, on the ribbon, click Arrange and, in the Position section, select one of the Vertical options:

The Position section of the Ribbon

If you select:

  • Equal Vertical: Microsoft Access will get the distance between the most top control or range of controls and the most bottom control or range of controls. It would also count the number of controls or ranges of controls between them, divide the distance by the number, and apply the result as the vertical distance among the horizontally aligned controls. The above selection would produce:
     
    Control Design: Position - Equal Vertical
     
    Notice that the distance between the top and the middle range is the same as the distance between the middle and the bottom range.
    If you click the Equal Vertical button again, nothing would happen
  • Increase Vertical: Microsoft Access would get the highest distance between two horizontal ranges (in this case the distance between the middle and the bottom controls). Then it would get the lowest (or lower in this case) distance between two horizontal ranges (in this case the distance between the top and the middle ranges). Microsoft Access would then calculate the average of these measures. Then, each set of the horizontal range of controls would be moved down by that value. Our original selection of controls would produce:
     
    Range Control Spacing: Increase Vertical
     
    Notice that the distance between the top and the middle controls is the same as the distance between the middle and the bottom ranges. At the same time, this distance is higher than the previous lower distance but lower than the previous higher distance.
    If you click the Increase Vertical button again, the controls would be moved down again. You can keep clicking to increase the distance
  • Decrease Vertical: Microsoft Access would get the highest distance between two horizontal ranges. It would also get the lowest (or lower in this case) distance between two horizontal ranges. Microsoft Access would then calculate the average of these measures. Each set of the horizontal range of controls would be moved up by that value. Our original selection of controls would produce:
     
    Range of Controls Spacing: Decrease Vertical
     
    Notice that the distance between the top and the middle ranges is the same as the distance between the middle and the bottom ranges.
    If you click the Decrease Vertical button again, the controls would be moved up again. You can keep clicking to decrease the distance. Once the controls from one range touch the controls of the higher range, the moving would stop

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:
     

     
    Here is the result in the preview:
     

     
    Notice that the distances among the ranges of controls are the same

Practical Learning: Spacing the Ranges of Controls Vertically

  1. On the form, click inside the vertical ruler on the left of the most bottom control (the Purchase Price label), hold the mouse and drag completely up to select all controls, then release the mouse
  2. On the ribbon, click Arrange if necessary and, in the Position section, click Decrease Vertical continually until the controls from one range touch the controls on the upper range
     
  3. Click the Increase Vertical button twice
     
  4. Save the form

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 and, in the Position section, you can click Equal Horizontal. In this case, the controls would be moved to be adjacent to each other. The above selection would produce:

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:

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:

  • Increase Horizontal: Microsoft Access would get the distances among the controls (in this case the distance between the left and the middle controls, and the distance between the middle and the right controls). Then it would calculate their average. Microsoft Access would then move the controls to touch each other so that the second from left would touch the left control; the third from left would touch the second, and so on. Then the controls would be moved to the right by the same distance each from the previous one. The above selection of controls would produce:

    Notice that the distance between the left and the middle controls is the same as the distance between the middle and the right controls. If you click the Increase Horizontal button again, the controls would moved to the right again by the same distance. You can keep clicking to increase the distance.
  • Decrease Horizontal: Microsoft Access would get the distances among the controls (in this case the distance between the left and the middle controls, and the distance between the middle and the right controls). It would calculate their average. It would decrease that value by one unit of grid line. The controls would be moved to touch each other so that the second from left would touch the left control; the third from left would touch the second, and so on. Then the controls would be moved to the right by that new measure distance each from the previous one. The above selection of controls would produce:

    Notice that the distance between the left and the middle controls is the same as the distance between the middle and the right controls.
    If you click the Decrease Horizontal button again, the controls would move to the left again. You can keep clicking to decrease the distance. Once the controls touch each other, the moving would stop.

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:
     
  2. Select the controls
  3. Click the Decrease Horizontal button continually until the controls touch each other. Here is an example:
     

     
    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:
     

     
    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:
     

     
    Here is the result in the preview:
     

     
    Notice that the distances among the controls are the same

Practical Learning: Spacing Stacks of Controls Horizontally

  1. Make sure that all controls are still selected on the form. Otherwise, select them.
    In the Position section of the Arrange category of the ribbon, click the Increase Horizontal button twice
     
  2. To preview the form, right-click the Company Assets tab and click form View
  3. Save the form

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 Order

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. In the Design View, you can right-click the form and click Tab Order... Alternatively, on the ribbon, you can click Arrange and, in the Page Layout section, you can click Tab Order. 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.
    Press Tab again and notice that you switch to the second record
  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

 

MCAS: Using Microsoft Office Access 2007 Topics

 
C7 Modify the design of reports and forms
 

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

Us Senate

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

Previous Copyright © 2008-2012 FunctionX Next