Access VBA Macro Programming

(Joao Candeias) #1

Click the Arrange tab in the ribbon. In the Control Alignment group on the ribbon, you
have icons to allow you to align all your controls to left, right, top, or bottom. For example, if
we have several text boxes that are displayed in a vertical row, but do not line up vertically
with each other, clicking the Left icon will line them all up on the control that is furthest left
within the selection.
This sorts out the alignment, but you may then have a situation where some are different
widths or heights compared to others. In the same ribbon used for alignment, you have a Size
group containing icons for To Tallest, To Widest, To Shortest, and To Narrowest. Click this
and all the controls in the selection will be set to the same height or width according to the
icon you clicked.
The Position group of the ribbon allows you to set the gaps between controls using the
Equal Horizontal and Equal Vertical icons.
Controls can be easily moved in minute increments in any direction by selecting the
control and holding down theCTRLkey. If you then press any of the arrow keys while the
CTRLkey is held down, your control will slowly move in the desired direction.
I have found this a really handy feature in Access for tidying up a report and making it
look more professional to the users.
You can also change the background color of the report and individual controls by setting
the Back Color property. If you are changing the background color of the report, you need to
click each section of the report (Report Header, Page Header, Section Header, Detail, and so
on) to change the background color. If you click the button with the three dots on it, in the
Background Color property you will see a palette of colors to choose from.
You can also add a picture to the background of the report. The Picture property will allow
you to upload a picture, which then becomes embedded in that form. This could be a picture
associated with that form or a company logo. However, remember that pictures take up
memory and too many can make your database unwieldy.
The picture property is on the overall report object itself, instead of the individual sections
(as in background color). You need to set the Picture Tiling property to Yes to make the
picture repeat down the length of the report. This feature can be very useful for adding a
company logo, although there is a danger of it detracting from the information on the report.
If you need other text on the report, use a label control and change the Caption property to
your text. As in all the controls, you can change the font, color, point size, and so on to suit
your needs.
You can set the Close Button property to No in order to stop the user using the Close
button to exit your report. Bear in mind that you will need to provide them with another
means of exiting if you do this.
You can also use the Min Max Buttons property to stop the user from changing the size of
the report, and do the same thing with the Control Box property.


Using Formulas on Your Report

A feature of reports is that you can include formulas to provide totals and other user
information.


Chapter 9: Forms and Reports 117

Free download pdf