Microsoft Access Tutorial: How To Resize Form Fields Dynamically Using MS Access VBA

Microsoft Access Tutorial: How To Resize Form Fields Dynamically Using MS Access VBA

I often see many poorly designed Access forms that just make it hard and clumsy to navigate and use. One particular element (and there are many) is the lack of area space for a text box control like comments or notes that require some intervention in order to edit the content properly.

Check out this Microsoft Access tutorial provided by ‘599CD Computer Training’ who provide some good and free video tutorials about Microsoft Access databases. On this occasion, it’s the best part of ten minutes but worth watching all the way to the end.

httpvh://www.youtube.com/watch?v=TC1QjUyOXi8

There are some good pointers here and to avoid using the SHIFT + F2 function key to zoom in on an active text box control, the author has suggested using some simple but effective Access VBA code.

microsoft access tutorial shift f2

Don’t worry too much if you are new to Access VBA programming, this will not stretch you at all and is simple to follow.

Microsoft Access Tutorial: How To Resize Form Fields Dynamically Using MS Access VBA

In my example, I’ve taken an Employee form and want to expand the ‘Notes‘ text box control so the height is increased when focusing on this control and then returns to the standard height when losing its focus.

Also note, the control below is another field (called ‘Label 42‘ which is the ‘Reports To’ field) which still reveals the caption and for completeness, I added another line of code to hide and then re-show it when losing its focus once again (see image below).

access database tutorial access vba height property

So by following the Microsoft Access tutorial (video above) and then with your own form delve into the Visual Basic editor using the methods as discussed, you will very quickly master the very basic coding technique of an Access database!

Simple but effective tweaks like this example will greatly improve the user’s workflow and experience and when adding other polished elements to a form, this will start to take a new dimension and level to your Access form designs.

Final tip for you: Get into the habit of naming controls that you intend to code or refer to in code as this will make easier to identify the correct control and avoid silly mistakes. In fact, why not take one step further and name all controls on a form as a matter of habit using the standard Microsoft Access set of conventions and disciplines (or create your own instead)?

Why not share your basic but effective Access VBA code tips below in the comments box?

Leave a Reply

Your email address will not be published. Required fields are marked *