Customized zoombox

#December 11th, 2017: Version 1.1: Fixed typo in download

Have you ever worked with the built in zoombox in access?

Standard Zoom Box

Access Standard Zoom Box

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.

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.

 

AutoKeys

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:

 

 

Download

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.

#December 11th, 2017: Version 1.1: Fixed typo in download

Download “CustomZoomBox.zip” CustomZoomBox-1.zip – Downloaded 62 times – 47 KB

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 🙂

4 comments on “Customized zoombox
  1. Giorgio says:

    Great stuff as usual, are you using any powerpivot or power Bi, Dax, R, M, Power queries? I see all these mouthwatering offers from Microsoft but I(or anyone I know) still can’t say that they offer something that the combination of Access with Excel can’t do when it comes to data management requests I face.

    • TheSmileyCoder says:

      Hi Giorgio. I have looked at most of them in more or less detail. And for self-service BI I suppose it could be usefull in some situations. The one situation where we tried to apply Power BI fully, we ended up with huge performance issues. Maybe we could have resolved them, but at that point it was a matter of what we can get billable hours on. And “playing around” with power BI isn’t one of them. I feel I have several techs that have been placed in the “when I hit a dry spell work wise, I will invest time in XYZ”. The “problem” is we are not seeing much dry spell lately :=)

  2. Steve Schapel says:

    One of the problems I have had recently with the native zoombox is that there is a huge delay when closing the zoombox if there has been any data edits. I don’t know if this is a common experience, but I have not been able to figure out the reason.

    Anyway, your custom zoom box solution has fixed that problem! 🙂 So I have implemented it in a few places, and am happy. Thank you.

    Having said that, I did need to make some tweaks before it would work for me. For example, there is a typo in your code at one point – “enable” instead of “enabled”.

    More importantly, the ‘get_controls_parent_object’ function, and the ‘grab_labelcaption_from_grid’ function (because it calls ‘get_controls_parent_object’) were throwing errors which I could not figure out. So I have simply bypassed them by directly calling ctl.Parent, and that works for me fine.

    Thanks again.

    Steve

    • TheSmileyCoder says:

      Thank you Steve. I have uploaded a corrected version. The initial download was extracted from another project, and probably introduced a typo along the way.

Leave a Reply

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

*