[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Whats New!
Need a database?
Tips via email
Learn VBA
Questions Answered
Access Tips Index
What is MS Access


Twips and Other Secrets to Sizing Forms and Reports

I do not know about all of you, but I have had considerable grief on setting the size of forms and reports. The windows seem to open up to whatever size they like. I usually get around this by Maximizing them, but there is another solution which is infinitely more flexible.

In this lesson we will cover Macros that will set the size of form and report windows.

We will cover:

• Maximizing the form;

• The MoveSize action;

• And finally, TWIPs, just in case you want to know what they are.

Maximizing a Form or Report

To maximize a form or report, open the form/report in Design view;

Right click on the upper left hand corner of the form or reports window (where the two rulers meet), a black square will appear;

Select properties from the drop down list;

Click on the ‘Event’ tab;

Place your cursor next to the ‘On Open’ event and click on the ‘…’ and select ‘Macro’, then ‘OK’;

Name the Macro and click on OK;

Now, in the ‘Action’ column in the first row, click the arrow and select ‘Maximize’ from the drop down list;

Close and save the Macro.

You can now add this macro to the ‘On Open’ event for any form or report you wish to Maximize on opening.

The MoveSize Action

Maximizing a form or report might not give you the result you want, this is where the ‘MoveSize’ action comes in handy.

To set the ‘MoveSize’ action in a Macro:

Open the form or report in Design view;

Right click on the upper left hand corner of the form or reports window (where the two rulers meet), a black square will appear;

Select properties from the drop down list;

Click on the ‘Event’ tab;

Place your cursor next to the ‘On Open’ event and click on the ‘…’ and select ‘Macro’ then ‘OK’;

Give the Macro an appropriate name then, click on ‘OK’;

Now, in the ‘Action’ column in the first row, click the arrow and select ‘MoveSize’ from the drop down list.

Unlike the ‘Maximize’ action you also have to select criteria as to where you wish the window to be positioned and what size you would like it.

So, at the bottom of the window set the four criteria:

*Right – set the distance you wish the upper left hand corner of the form/report window to be from the edge of the left hand side of the screen (either in inches or cm);

*Down - set the distance down you wish the upper left hand corner of the form/report window to be from the ruler (either in inches or cm);

*Width – set the width you wish the window to be (either in inches or cm);

*Height – and, finally, set the height.

Close and save the Macro.

You can now add this macro to the ‘On Open’ event for any form or report you wish to set the size of the window on opening.

The ‘MoveSize’ action may need to be built and individualized for each individual form/report, if you want them to be different sizes. Keep this in mind when you are naming the Macro.

Twips

A form’s height and width can also be set using the ‘SetValue’ action of a macro.

This is handy to know if you wish to change the size of the form at another time other than when you open the form. The ‘MoveSize’ action can only be used for the current form or report.

Follow the steps above, but choose ‘SetValue’ from the drop down list of the Macro;

Then, in the ‘Item’ section, choose the following using the ‘…’;

Forms![Form1].InsideHeight

(Where Form1 is the name of the form you wish to set)

Set the InsideHeight measurement in the ‘Expression’ box;

The measurement of the inside height/width are in twips. What you need to know is that twips are very small. There are 567 twips in a centimetre.

Select ‘SetValue’ again in the second row in the ‘Actions’ Column;

This time select:

Forms![Form1].InsideWidth

Please Note: The InsideWidth and InsideHeight properties are only available for forms and not reports.

 

Do you like this tip? Subscribe to my weekly Newsletter to receive tips weekly via email. Click Here to subscribe.

footer for Microsoft Access page