Have you ever worked with the built in zoombox in access?
Now the concept behind it is great. It allows for you (and users) to zoom in on the contents of a control. It could be that the textbox is too small to hold the contents (i.e. very long text strings) or it could simply be that the font is too small. I’ve used the zoom functionality especially while in meetings, where I want to blow up the contents for meeting guests in the back to see as well.
However, in my opinion the built in zoom box has some limitations:
- The list doesn’t remember the font size you selected last, so if you need a larger font, then you have to reset it each time.
- The form cannot be resized. Users cannot make it larger if they need to.
- The form layout if fixed, and cannot be modified to fit your layout.
But it also comes with the following usability flaws:
- The form doesn’t take into account whether the underlying control is editable or not. So users make edits, and wonder why their edits are not being saved.
- The form doesn’t take the original font into account. Say you use a special company font, or barcode font, or something like wingdings. When you zoom in, the result might look radically different than the source.
A long time ago, I decided to fix this, and wrote a custom zoom form I’ve used in several projects since, and people have really liked it. I’ve been meaning to put it on the blog for a while, and a recent thread on ExpertsExchange finally gave me the nudge I needed to write the blog post.
Custom zoom box
So I created a custom form, which can be used from code, or autokeys(more later), which is context sensitive as to whether the control/form/report is locked, as well as which font is used, it picks up the label bound to the control, can be resized, themed, coloured, and more. It remembers the users font size settings in an external variable, and is in my opinion much more user friendly.
And just to point out what happens if the control is not updateable (locked, recordset not updateable, or otherwise), you can see a different screenshot below.
Now there are 2 main ways of activating the userform. If you as developer want to be more in control of when and how they use the form, you can code the usage directly. My favorite approach is to use the double click event.
Private Sub txtMainCategoryName_DblClick(Cancel As Integer)
All the rest of the “plumbing” is handled directly from the form. You literally have to do no other coding. The form itself will automatically detect if the source control is locked, or in another way not updateable.
If you want, you can pass in a custom label caption in the openargs, which will then be shown in the userform, but it is not required. If nothing is provided, the form will automatically try to grab the caption from any attached label, or from any layout bound label in the same column.
Now, if we want to make it really easy on ourselves, we can use an autoexec macro. Its just a macro in your project, with the name “AutoKeys”. In here, I define that “Shift-F2” shall simply open my userform. As the rest of the plumbing is contained in the userforms code, we need nothing else. Now users and zoom any control in your database (if that makes sense, i.e. they still cannot zoom a varBinary field or a checkbox). You can see my simple macro below:
So the download below contains both the userform, as well as the autokeys macro, should you wish to use it. Try to import both into your project, and then go ahead and hit Shift-F2 from one of your forms, to see the zoom box in action.
If you found this usefull, please take the time to come back with a comment here. If you find any bugs, please let me know, so I can fix it up 🙂