Assigning Auto Keys for Aligning Controls

        1 vote: *         3,533 views      0 comments
by Allen Browne, 20 April 2005    (All versions of Access)

Microsoft Access Tips for Casual Users

Provided by Allen Browne, allen@allenbrowne.com


Assigning Auto Keys for Aligning Controls

If you have used the Wizards to create forms and reports, you will have also tried dragging controls to a new location in Design View. Moving PostalCode beside Town makes sense, especially if all controls don't fit on screen. You've probably figured out how to move a control separately from its label (larger black square at top left when the control is selected), how to select multiple controls (hold down Shift), and how to make a control just the right size ("Fit to Size" from the Format menu).

Getting controls to align correctly after dragging them around can be a chore! "Snap to grid" is useful, but often doesn't give the precise placement you want.. Too often you find yourself roughly aligning the controls and then going to the Format menu (Layout in Access 1) to get Align, Left for text boxes and Align, Right for labels. Then you select the ones on the same row and go back to the menu for Align, Top or Align, Bottom.

A keystroke such as Ctrl+L for align left or Ctrl+R for align right could speed things up. Here are the steps to get that result.

  1. Create a new macro and save it with the name AutoKeys. (The name is important.)
  2. If you cannot see a column called "Macro Name", check Macro Names on the View menu.
  3. In the first row of the Macro Name column, enter ^L i.e. a caret (above the 6 at the top of the keyboard) and an L. Access interprets the caret as referring to the Ctrl key.
  4. In the Action column beside this, choose RunCommand. Then in the lower pane, choose the command AlignLeft.
  5. In the second row, enter ^R under Macro Name, and RunCommand under Action. In the lower pane, choose AlignRight.
  6. Enter another two rows using ^T for AlignTop, and ^B for AlignBottom.
  7. Save the macro, and test it. Select two or three controls that are not aligned correctly, press Ctrl and L together, and watch them move into place.

* Access 2: Choose DoMenuItem as the action, and in the lower pane, Form Design, Format, Align, Left.
* Access 1: Choose DoMenuItem as the action, and in the lower pane, Form Design, Layout, Align, Left.

There will probably be other operations to add to this macro to cover your needs. Try to avoid reassigning standard Windows keystrokes such as Ctrl+C and Ctrl+V (copy and paste).

screenshot

By the way, did you know that an ampersand (&) can give you a keyboard shortcut to a control? For example, type &Animals as the caption for a button and Access underlines the "A" indicating that you can move the focus to that button with Alt+A.


Home Index of tips Top

Rate this article:   Your rating: Poor Your rating: Not so good Your rating: Average Your rating: Good Your rating: Excellent


This is a cached tutorial, reproduced with permission.

Have your say - comment on this article.

What did you think of 'Assigning Auto Keys for Aligning Controls'?

No comments yet.

Why not be the first to comment on this article?!

Have your say...

Name
E-mail (e-mail address will be kept private)
Comments
Verify Code
Verification Code


It may take 30 seconds after clicking submit - please be patient to avoid duplicate submissions.  

All comments must be approved before being displayed on this web page.  This process may take up to 24 hours.