A better ZoomBox

by Tom van Stiphout 17. May 2014

Introduction

Hit Shift+F2 on any textbox or similar control, and Microsoft Access will open the built-in ZoomBox.
In this screenshot I am in the Northwind sample application, product detail form, and I could not quite read the name of the product because the textbox is too narrow. So I hit Shift+F2 and the ZoomBox comes up with a larger textbox so I can see the entire text.

Standard ZoomBox

That's nice, but this zoom box leaves a lot to be desired. Some of the problems include:

  • The text in the ZoomBox is selected, which makes it hard to read.
  • The text font is very small.
  • You can change the font size, but Access forgets this when you close the application.
  • The form is not resizable, which makes it hard to use for large amounts of text.
  • ZoomBox cannot handle rich text.

Unfortunately Microsoft appears to have ignored this handy tool, or they would have spent a few hours per version on keeping it up to date. And before you say that they are now focused on the web version of Access that runs on SharePoint: that is true but in that environment the ZoomBox is gone altogether. I am one of many Access developers who thinks the Access client application has many more years of life in it. If Microsoft neglects it, perhaps the community can step up and fill some of the gaps. The improved ZoomBox I am presenting here today is one of those efforts.

A better version

The improved version I am presenting addresses all of the limitations listed above.

Improved ZoomBox

It is very simple to use this ZoomBox in your application. Here are the steps:
  1. Download the zip file with the sample file from the link at the bottom of this post.
  2. From ZoomBox.accdb copy frmZoom form, modFontPicker module, and AutoKeys macro to your application.
  3. Use code window > Tools > References and set a reference to Microsoft Scripting Runtime.
That's it!

Some finer points

The sample application was created using Access 2007 and the Northwind sample database. If you are using an older version of Access you are welcome to port ZoomBox to your version. You will have to write a bit of extra code because I am using features like control anchoring that are not available in older versions. If you send me your version I will post it here.

With the new code in place, how does the ZoomBox come up? It starts with the AutoKeys macro. This is a special macro which must have this name. Access uses it to look for special keystrokes. +{F2} codes for Shift+F2 and the macro then opens frmZoom.
frmZoom's Form_Open event checks if there is an active control and if it has a Text property. If not, Cancel is set to True and the ZoomBox closes before you could even see it. If all is good we grab the text and display it in the zoom box. We also read settings from the registry with regards to location and size of the form and the font settings, and use them to initialize the ZoomBox the same way you had last left it.

The rest of the code should be self-explanatory and is well documented. Please let me know if anything is not clear.

Summary

In this blog post we presented a better version of the Access ZoomBox, which addresses many limitations of the built-in one.

You can download a zip file with the download package here.

Comments are closed