Automatic control resizing with form resizing in MS Access
A module by Alex Wellerstein. 

Please feel free to use this code however you wish. There are no
copyright requirements or licensing stipulations. 

How to use this code:

Import formResizer.bas into MS Access as a Module.

Make sure that Make sure that "Microsoft Scripting Runtime" (scrrun.dll)
is added in the "References" to the project. This is necessary as the
module uses the Scripting.Dictionary object.

Then, for each control that you want to resize, change its tab property
to "Lock-#" where # relates the following chart:

     L - Lock Left (left side of control is locked into place)
     R - Lock Right (right side of control is locked into place)
     T - Lock Top (top of control is locked into place)
     B - Lock Bottom (bottom of control is locked into place)
			
By combining these, you can get different types of control behavior.

For example, if you had a text box that you wanted to expand
horizontally as you resized the form window, you would set its Tag
property to "Lock-LR". That is, you would tell it to lock the relative
positions of the left and right boundaries in place. 

If you wanted a control that maintained the same distance from the right
edge of the form, but was not resized (that is, the left border could
move), then you would use "Lock-R". 

To make a control stay the same distance from the bottom of the form and
never resize, you would use "Lock-B". To make a control which was
resized vertically as the form was resized, you would use "Lock-TB". 

And lastly, to make a control that automatically resized itself
horizontally and vertically at the same time, use "Lock-TBLR" (or
"Lock-LRTB" -- the order of the locking letters does not matter). 

After annotating the controls (see the example MDB file provided if the
above is completely mysterious), all you need to do is add the following
line to the Form_Resize function:

	formResizerResize Me.form
	
Simple, no?

The module contains two subs, formResizerResize and formResizerInit. The
latter function takes measurements of all of the controls relative to
the borders of the form which are used in order to maintain the relative
positions of the controls as they are resized. formResizerResize does
the actual resizing. You don't need to call formResizerInit yourself; if
formResizerResize runs and detects that you haven't yet initialized the
resizer for that form, it will initialize it for you. Both subs take one
argument, which is the form you are resizing (usually the same form
designed by Me.form). 

Once formResizerInit has run the resizing function no longer needs to
access the Tag property of the control directly. So if you need the Tag
properties for anything else, that is not a problem as long as you make
sure the formResizerInit function runs before you try to change the Tag.


General disclaimer: This code is released without any warranties
whatsoever. Use at your own risk. It has been run on my own computer and
didn't do anything unpleasant. It is unlikely that it would cause any
damage to your computer or your data (it does nothing with your data at
all). But just the same if something freakish occurs, I'm not going to
be responsible for it. Good luck!

