Mendip Data Systems

Database applications for businesses and schools

LogoTransparent

ResizeForm Me - A Tutorial in Automatic Form Resizing :     Part 2 (of 3)

 

 

Colin Riddington      Mendip Data Systems        Updated 24/01/2020

* Required

To provide feedback on this article, please enter your name, e-mail address and company (optional) below, add your comment and press the submit button. Thanks

Click the links to download various items related to this topic:

 

1.   The original auto form resize utility by Jamie Czernikafr.zip (MDB zipped)

 

2.   The example application referenced in this article  - ResizeFormExample_v2.6.zip (ACCDB file zipped)

       

3.   The complete article as a PDF document – ResizeForm Me_2.6.pdf (PDF zipped)

 

 

I would be grateful for any feedback on this article including details of any errors or omissions

If you have any comments or questions, please contact me using the feedback form below or by email 

Difficulty level :   Moderate

Click any image to view a larger version

Adding a Zoom feature

Unlike Word and Excel, there is no built in zoom control available in Access. For those with less than perfect eyesight this can be an issue.

 

I have now added two additional forms to the example application to show how Access forms can be zoomed in/out using a modified version of the resizing code.

 

The new code in Form3 allows further adjustment of the form from 75% to 125% of the default size for your screen & resolution

Use the combo or slider control to adjust the scale in 5% intervals according to personal preference.

The form dimensions and all controls SHOULD be adjusted accordingly

For example, with zoom = 125% 

The zoom level can be reset to normal by clicking the 100% button

 

NOTE:

1.   Increasing the zoom may cause part of the form to move ‘off screen’ as in the screenshot above. Scrollbars appear automatically when this happens

 

2.   The slider is an ActiveX control. This will be hidden and ‘inactive’ if you have disabled ActiveX controls in Access Options Trust Center

     At some point in the future, I will replace this with a non-ActiveX slider control

 

A very simple popup form is also available which includes a zoom feature with a range 50 – 150%

Once again, click the 100% button to reset the form to its default size and scale

Using the example applications

The attached application ResizeFormExample_v2.6 has been designed for use with BOTH overlapping windows AND tabbed ddocuments.

 

It contains three almost identical versions of the main form shown above:

•   frmExample1 automatically resized on form load

•   frmExample2not resized on form load BUT can be resized by clicking a button in the form header

•   frmExample3 – automatically resized on form load PLUS the new ZOOM feature

Each form also includes a subform

 

The example application also contains these forms:

•   frmPopupZoom – as shown above

•   frmFormUnresizer – use to fix issues if forms become 'over-enlarged'

•   two template forms 800x600 and 1024x768 - use to assist with setting a default form size at different 'design resolutions'

 

 

NOTE:

The main forms used in this example were originally designed to demonstrate the use of the Tag property to make groups of controls visible/hidden,

enabled/disabled, locked/unlocked.

 

In this screenshot, controls with tag A have been hidden, tag B controls locked and tag C controls disabled.

AFR20

All the code used in that feature is contained in the module modControlState

For more details, see http://www.mendipdatasystems.co.uk/set-controls/4594398114

 

NOTE:

Not all controls can be hidden / disabled / locked.

The subform summarises the properties available for each control type

AFR21

Possible Issues and Solutions

The automatic form resizing code is most successful with maximised forms.

If using non-maximised forms, you should check the effect of resizing at different resolutions.

If necessary, adapt the form size/shape for best results.

 

NOTE: Built in Access forms such as message boxes, input boxes and error messages are NOT resized.

 

Popup forms appear on top of the application window and therefore may not fit fully on the screen if resized.

It may be necessary to exclude certain popup forms from being resized.

 

The original version of this code by Jamie Czernik from 2003 did not always work properly with the tabbed documents display option added with Access 2007.

For example, certain controls such as subforms and tab controls were shifted off screen causing the whole form to be shifted both horizontally and vertically

AFR22 AFR23 AFR25 AFR24 AFR26

The cause of the problem can be seen in design view. The frame borders (ORANGE lines) have become over enlarged

This causes the entire form to scale up more than necessary

Luckily this is an extremely rare event if the form is well designed.

 

However, it can be an issue if the option group is near the bottom or right edge of the form.

To prevent this issue, place option groups as far left and near to top of the form section as possible.

 

The following quote is taken from the help file supplied with the original code by Jamie Czernik:

Tab controls and options groups are difficult to resize as Access tries to keep the child controls within the frame while the child controls are being moved and resized. This can lead to distortion if the controls are too close to either the top/bottom or left/right of the form being resized.

 

If your forms tend to be scaled up to higher resolutions, then try to keep tab controls and option groups as far left and near to top of the form section as possible.

The reverse is true if forms tend to be scaled down to lower resolutions so in this situation try to keep them as far right and near to the bottom as possible.

If a form does become ‘over enlarged’ it can be fixed using one of these methods:

 

a)  Open the FixFormSize procedure in modResizeForm and enter the form name where indicated

    Run the procedure whilst the form is open in design view 

b)  Use the form frmFormUnresizer suppied with the example app. Select the over enlarged form from the list then click Shrink Form

AFR27

Whichever method you use, the form will be scaled down and controls shifted back into the correct positions.

AFR28 AFR29

However, you will still need to restore the original size of the option group controls that were over enlarged.

Once you have done so, you need to then reduce the height and width of the form yourself.

 

NOTE: 

It can be useful to create a box control with a transparent fill in each section which is the correct height and width for that section

This makes it very easy to restore the form to the original size

Finally save and close the form

 

NOTE: 

If you make a mistake, the process can if necessary be reversed by clicking the Enlarge Form button

Using automatic form resizing with your own applications

You will just need to import the module frmResizeForm and (optionally) form frmFormUnresizer.

Then follow the instructions as above adding ResizeForm Me to the Form_Load event of any forms to be resized.

Click any image to view a larger version

Return to Home Page Return to Access Articles 1 2 Return To Top
Page 2 of 3
AFR30 AFR31

Or with zoom reduced to 75% 

AFR32 AFR33

NOTE:

The display issue shown above MAY not occur with popup forms containing tab controls. It NEVER occurs when using overlapping windows

 

Using both scrollbars, the form can be correctly ‘realigned’.

Similarly, if the navigation pane and / or ribbon is maximised then minimised again.

However even if the form was saved after doing so, it would again be shifted the next time it is opened

 

The original partly successful solution was to apply a tag value = 1 to the form.

Doing so triggered ‘exemption code’ in the ResizeForm procedure to be implemented.

 

However, the latest version (2.6) of the resizing code supplied with this article works equally well with both overlapping windows and tabbed documents.

The code detects the display option by checking the UseMDIMode property. This is is 1 for overlapping windows or 0 for tabbed documents

After resizing, the revised code maximizes then minimizes the navigation pane if tabbed documents are in use

Tab control in the correct position

Tab control headers shifted off screen

 

Datasheets CANNOT be resized. Recommend instead using a continuous form to emulate a datasheet

 

Button captions may not quite fit when forms are resized for small screens such as a tablet

To prevent this issue, ensure the button width is slightly greater than the length of the caption.

 

Option groups can occasionally become ‘over enlarged’ switching between form view and design view during the development process.

This can cause the entire form to expand far more than required

Doing this is sufficient to reset the form positioning correctly.

It has been tested successfully with document tabs both visible and hidden. No fix is required for overlapping windows

 

Nevertheless, it is STRONGLY RECOMMENDED that forms are both designed and displayed using the same display option.

 

 

UPDATE 24/01/2020

Many thanks to Utter Access member ollyhutsy for informing me of an issue for users running runtime versions of Access

Code to maximise/minimize the navigation pane fails in runtime versions. However the original code setting the form tag value = 1 still works

 

So there are two possible solutions for runtime users:

1. Using tabbed document display - set the form tag value = 1

2. Change to overlapping windows display (RECOMMENDED) -  that works perfectly without needing any code tweak.

AFR34 3