Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Zoom on Click < Attachments | Popup Over Control >
Zoom on Click
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   11 months ago

Auto-Open Zoom Box with One Click in MS Access


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark Join Now

In this Microsoft Access tutorial I will show you how to open the Zoom Box with a single click on a designated field using just one line of VBA code, and how to add a Zoom button that works on any field by setting focus to the last active control. We will cover using the On Click event for fields and buttons, discuss the SetFocus and Screen.PreviousControl methods, and address some common usability tips for working with Zoom in Access forms.

Members

There is no extended cut, but here is the file download:

Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the files from class plus get access to the Code Vault. If you're not a member, Join Today!

Prerequisites

Links

Recommended Courses

Learn More

FREE Access Beginner Level 1
FREE Access Quick Start in 30 Minutes
Access Level 2 for just $1

Free Templates

TechHelp Free Templates
Blank Template
Contact Management
Order Entry & Invoicing
More Access Templates

Resources

Diamond Sponsors - Information on our Sponsors
Mailing List - Get emails when new videos released
Consulting - Need help with your database
Tip Jar - Your tips are graciously accepted
Merch Store - Get your swag here!

Questions?

Please feel free to post your questions or comments below or post them in the Forums.

KeywordsZoom on Click in Microsoft Access

TechHelp Access, zoom box vba, pop up zoom window, vba on click event, zoom on field click, acCmdZoomBox, single line vba, open zoom box, setfocus vba, previouscontrol setfocus, debug compile vba, zoom via button, zoom box command, enlarge field vba, error handling vba, activecontrol property

 

 

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Zoom on Click
Get notifications when this page is updated
 
Intro In this video, I'll show you how to open the Zoom Box with just a single click in Microsoft Access using one simple line of VBA code. We'll cover how to trigger the Zoom window by clicking on a specific field, how to add a Zoom button to your form, and how to make the button work for any field by using SetFocus and Screen.PreviousControl. I'll also talk about basic error handling with On Error Resume Next and walk through accessing form properties and setting up the On Click event.
Transcript Today we have a developer-level video for you, but I'm marking it easy because you only need one line of code to do this. However, you have nowhere to put that one line of code. So today, we're going to learn how to zoom on click. In other words, when you click on a field that you designate, like your notes field here, just click on it and poof, the zoom window will pop up.

This is easy. No longer do you have to remember to use Shift+F2, which your users probably forget anyway. I'm going to show you how to do it with just a single click.

Now, even though this is easy, I have a couple of prerequisites for you. If you don't know what the zoom box is, go watch this video and I'll fully explain it. Basically, you can zoom into any field you want. You hit Shift+F2 and poof, there's a zoom box.

Like I said, we will only be using one line of VBA code, but if you've never done any VBA programming before, go watch this video first. Don't worry. It's not scary. It's about 20 minutes long and will teach you everything you need to know to get started. Then come back and watch this video.

There's one more you should watch: my On Click Event Button video. We're going to use the on click today, so when we click on that field, the event runs and opens up the zoom box. Go watch this if you want to learn more about on click. These are all free videos. They're on my website and YouTube channel. Watch those and then come back.

Here I am in my TechHelp free template. This is a free database you can grab a copy of from my website if you want to.

The nice thing about the zoom is if you can remember it's Shift+F2, you can click on it and zoom in anywhere. I use it a lot for class. You can use it in tables and queries. If you open up a query and want to get in here, you can zoom in. You can use it in design view. I use it all the time in design view. We're opening this up. If I want to go in here or see what the record source might be, I'll click over here and hit Shift+F2. It's system-wide within Access. You can't use it in your other program like your music player.

The problem we sometimes have is that it's such a neat tool for us as developers, and I can remember Shift+F2, but do your users? You might want to have it so that when you click on the notes field, the zoom window will just pop up automatically. Or you can put it in a button if you want to as well. I'll show you both methods.

First, let's put it in the on click event of this notes field. I do this for a few fields in my personal database because there are a couple fields I like to keep small, just so I can see that there are notes in there, but if I want to read them, I can click on the field and it pops up the zoom box.

Open up the properties. If you don't know what I just did, by the way, I just double-clicked on the border here, or you can right-click and go down to properties.

Now find the Events tab. Find On Click. Click the build button over there. That's going to open your VBA code window. You don't need the Project Explorer. We're going to turn that off.

So I'm in Notes_Click. You're ready? It's one line of code. It's going to be:

DoCmd.RunCommand

And then there's a whole bunch of stuff in here. You're going to type in:

acCmdZoom

Ignore all of these with numbers on them. Those are for reports, so you can change the zoom level of a report (20, 150, ignore all those). Come down to the bottom. Ignore Selection too. We don't want that one. That's also for reports. What you want is this one right here: acCmdZoomBox. That opens up the zoom box.

That's it. You're done. Every time you click on the notes field, that command will run. Save it. Debug -> Compile once in a while to make sure your code is good. You can close it, then open it.

Now, when I click on this box here, look at that! It pops right up for me. You can hit Cancel or OK. If you hit Cancel, it ignores any edits. If you put a bunch of edits in here and hit Cancel, it doesn't save those. But if you click OK, it'll save your changes.

That's important. I've made some changes before and then hit Cancel, so don't do that.

Now if you think you might want to sometimes be able to click on this, and you find that annoying, or if you want to maybe put a little zoom button down here, you can do that too. Sometimes I'll do that.

Let me just get rid of these for the purposes of class. Let me turn off that on click for that field. I'm going to come in here and just remark that out so it doesn't fire.

Now we can put the same thing in a little button. I just copy and paste that button, slide it under here, and put "Zoom" on it. You can make it small. You can change the color. You can do whatever you want. Give it a name; otherwise, Alex will yell at us. Name it ZoomButton.

Right-click, Build Event. Build Event is the same as the Click for a button. Then we'll just copy and paste this code. Save it. Debug -> Compile once in a while. Close it, then open it.

Ready? Click. Oh. Actually, the command zoom box isn't available. Now why did that happen? What's going on? The debug won't run it.

Let me think about this for a minute. This runs and opens the zoom command. Oh, but when we click on a button, we're sitting on the button. You can't zoom into a button, can you? So we just have to move the focus of where the cursor is. Which control has focus? Focus is where the cursor is sitting. So we're going to say right here:

Notes.SetFocus

We're going to move to the notes box, then click that button, then run the zoom command.

Ready? Save it. Close it. Close it again. I always close my forms anytime I make a VBA change. That's just a personal habit. It makes sure everything resets clean.

Now when I click the button, watch what happens. Boom. It moves the focus there first, then runs the code.

If you want to learn more about SetFocus, go watch this video. I have videos for pretty much everything.

One more quick thing and then I'll let you go. I said I was going to keep this easy and I am. But wouldn't it be nice if this button worked with any of these fields? Check this out.

Watch this. Design view. I'll just move this over here so no one thinks it's associated just with the notes field. Watch what I'm going to do. I'm going to say "go back to what the last field that you were on was." Right-click, Build Event. Instead of setting focus back on the notes field, I'm going to say:

Screen.PreviousControl.SetFocus

In other words, whatever control you were on last, set the focus to it. Because it might have been a button or something else, you might not be able to run that. So I'm going to throw an "On Error Resume Next" in here. That just says if you do encounter an error, just ignore it. So if the user was on another button first and they try to run this, nothing will happen. But if they were on a text box or something you can zoom into, it will zoom in.

Debug -> Compile. Close it. Save changes, yes. Open it up.

Now, if I click on the notes field and then hit Zoom, it goes back to the notes field. If I click on my last name and hit Zoom, it zooms into the last name field. Go to the country, Zoom. Now if I happen to be on something like a checkbox that you can't zoom into, nothing happens. You could pop up an error message if you want to, but that involves a little more error handling.

If I'm on a button, let me tab over to a different button. Let's see. I'm on the context button, and if I hit Zoom, nothing happens. If you are on something like that and hit Zoom, nothing happens.

If you want to learn about that PreviousControl property, I have a video on that and its close cousin, which is ActiveControl. You can do some cool stuff with the control that you're actively on right now.

In my original zoom video, the first one I told you to go watch, and the extended cut, I show you a trick how to make the field itself larger. So it doesn't open the zoom box, it just makes the field bigger. Here's the extended cut. Let me zoom in for you so you can see it better. You click on the field and it just makes the field bigger; it makes the font size larger and all that stuff. That's covered in the extended cut for the original zoom video that I showed you.

Do you like this stuff? Do you like learning with me? Do you want to learn more VBA? As you can see, with just one line of code or just a couple lines of code, you can make your database do some really cool stuff. In my developer course, I show you all the cool tricks like this to make your database as awesome and powerful and worthy of Starfleet. I also have some advanced stuff to show you.

Check it out. You'll find a link down below.

That's going to do it for today, folks. I hope you learned something in this TechHelp video. Live long and prosper, my friends. I'll see you next time.

TOPICS:
Using VBA to open the Zoom box on field click
Accessing control properties and events
Adding code to a field's On Click event
Using DoCmd.RunCommand acCmdZoomBox
Creating a Zoom button on a form
Setting focus to a control with SetFocus
Combining SetFocus with the Zoom command
Making a Zoom button work for any field
Using Screen.PreviousControl.SetFocus
Basic error handling with On Error Resume Next

COMMERCIAL:
In today's video, we're learning how to make the Zoom Box appear with just a single click in Microsoft Access. Instead of remembering Shift+F2, I will show you how to use one simple line of VBA code to open the Zoom window when you click on a field or press a button. We will cover setting up the On Click event, using SetFocus to make sure the zoom works from a button, and using the Screen.PreviousControl property to zoom into whichever field you were last on. You'll also hear about related videos covering ActiveControl and how to make fields larger instead of using the Zoom box, which are explained in the extended cut of the original zoom video. You'll find the complete video on my YouTube channel and on my website at the link shown. Live long and prosper my friends.
Quiz Q1. What is the primary purpose of using the zoom box in Microsoft Access?
A. To automatically save records to the database
B. To open a larger editing window for a field
C. To filter records based on field values
D. To export data to Excel

Q2. Which keyboard shortcut opens the zoom box in Access by default?
A. Ctrl+Z
B. Alt+F2
C. Shift+F2
D. Ctrl+F

Q3. Why would a developer want to trigger the zoom box with a mouse click instead of using Shift+F2?
A. To allow easier access for users who might forget keyboard shortcuts
B. To prevent accidental data changes
C. To automate database backup
D. To lock the field from editing

Q4. What event property is used to run code when a user clicks on a field in Access?
A. On Open
B. On Focus
C. On Click
D. On Load

Q5. What is the correct VBA statement to open the zoom box for a control?
A. DoCmd.OpenZoom
B. DoCmd.RunCommand acCmdZoomBox
C. Application.Zoom acCmdZoomBox
D. Control.ZoomBox

Q6. When adding the zoom code to a button's Click event, what problem must be addressed for it to work?
A. The button must be placed inside a subform
B. The focus must be set to the target field before running the zoom command
C. The form must be set to design view
D. The database must be recompiled every time

Q7. What line of code is needed to move the focus to a control named Notes before opening the zoom box?
A. Notes.Select
B. Notes.FocusOn
C. Notes.SetFocus
D. Notes.GainFocus

Q8. How can you make a zoom button that works for any field you were last on?
A. Always set focus to the Notes field before zoom
B. Use Screen.PreviousControl.SetFocus to return to the previous active control
C. Use Screen.NextControl.SetFocus to move forward
D. Hard-code the button to only work with a specific field

Q9. Why might you add On Error Resume Next before setting focus and opening the zoom box?
A. To display detailed error messages
B. To loop through all form controls
C. To prevent errors when trying to zoom into non-zoomable controls like buttons or checkboxes
D. To save data automatically

Q10. What happens if you click Cancel after making changes in the zoom box?
A. All changes are automatically saved
B. Only numeric values are saved
C. All edits are ignored and not saved
D. The whole form closes

Q11. What does Debug -> Compile do in the context of writing VBA code in Access?
A. Runs the form in design view
B. Checks the code for syntax errors and compiles it
C. Automatically saves a backup of the project
D. Formats the code for better readability

Q12. According to the video, what is a benefit of making a field itself larger instead of using the zoom box?
A. It allows data to be filtered easily
B. Users can see and edit more information directly without opening a separate window
C. It protects the field from accidental edits
D. It disables keyboard shortcuts

Answers: 1-B; 2-C; 3-A; 4-C; 5-B; 6-B; 7-C; 8-B; 9-C; 10-C; 11-B; 12-B

DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.
Summary Today's TechHelp tutorial from Access Learning Zone will show you how to create a one-click zoom function for any field in your Microsoft Access forms. Although you only need a single line of VBA code, the real trick is learning where to put it. This is an easy task once you know the right place to add the code, and it makes zooming into fields (like notes fields) much more convenient for you and your users.

Many users forget about the built-in Shift+F2 shortcut to access the zoom box. To solve that, I will teach you how to launch the zoom window simply by clicking on a field. No more struggling to remember keyboard shortcuts.

Before you get started, make sure you are familiar with the zoom box feature in Access. If this is your first introduction to the zoom box, I recommend watching my dedicated video on that topic, where I explain exactly how it works. In Access, the zoom box lets you blow up a field for easier viewing and editing by pressing Shift+F2. This works in tables, queries, design view, and other areas inside Access, but it's exclusive to Access and won't function in other programs.

You will need to enter one line of VBA to make this work. If you are new to VBA programming, please check out my beginner's guide first. It's about 20 minutes long and will get you comfortable with the basics. Once you've watched that, come back to this lesson.

You should also be familiar with how event handlers work, particularly the On Click event. I suggest watching my video on the On Click Event Button to grasp how events are triggered in your forms. All of these foundational videos are freely available on my website and YouTube channel.

I am demonstrating this technique in my TechHelp free template database, which you are free to download from my website.

Normally, if you remember Shift+F2, you can bring up the zoom box anywhere in Access by hitting that key combination. As a developer, I use the zoom box all the time in fields that might have more text than comfortably displays. Unfortunately, most end users are not likely to remember this feature. That's why adding a one-click zoom option can make your application much more user-friendly. You can either set up a field so clicking it brings up the zoom box, or you can add a separate zoom button.

Let's start by adding the feature directly to the notes field. This is practical for fields you like to keep small yet want to allow quick access to all the contents. To do this, open the field's properties. If you are unfamiliar with the properties window, you can access it by double-clicking the edge of the control or right-clicking and selecting "Properties". Navigate to the Events tab and locate the On Click event. Build the event procedure, which will open the VBA editor. You do not need any extra navigation panes open.

Inside the event, you only need to add a single command to trigger the zoom box. Among the various RunCommand options, make sure you use acCmdZoomBox. Many options have numbers following them, but those are for adjusting report zoom in print view, so only acCmdZoomBox is relevant for this task.

Once you have that in place, any time you click the designated field, the zoom window will appear. You can accept your changes with OK, or discard them by clicking Cancel. Any changes made but not saved with OK will not be committed to the field, so bear that in mind.

If you find it distracting or unnecessary for the zoom box to appear every time you click the field, or if you want more flexibility, you can attach this functionality to a dedicated button instead. This is also helpful if you have multiple fields where zooming in would be useful.

To do this, remove or comment out the code in the field's On Click event. Add a button to your form, perhaps below the field, label it "Zoom," and give it a clear name like ZoomButton. Assign a click event to the button. You can reuse the same DoCmd.RunCommand line you used before.

However, you will quickly discover that running the zoom command from a button click does not work by itself. Access cannot zoom into a button, so you need to shift the focus back to the field you want to zoom into before running the command. Add a line that sets focus to the notes field before the zoom command runs.

Now, clicking the button will shift focus to the field and open the zoom box. Remember to save and close your form after making changes in VBA to ensure all updates are applied.

If you want your zoom button to work regardless of which field you were last on, you can use the PreviousControl property. Set focus to the last control you interacted with before clicking the button, which allows the zoom feature to be more dynamic and not tied to a single field. Since not all controls can be zoomed (such as buttons or checkboxes), you'll want to add a little error handling, like "On Error Resume Next," so the code continues smoothly even if zoom is not available for a selected control. If you would like to display an error message for unsupported controls, this would require additional error handling.

Once this is set up, clicking the zoom button will activate the zoom box for whichever field you were most recently in, provided it supports zooming. If not, nothing will happen.

For those interested in deeper control of forms, I have further videos covering properties like PreviousControl and ActiveControl, which let you create even more interactive forms.

In my original zoom video's extended cut, I demonstrate how to make the entire field larger when clicked, instead of opening the zoom box. This technique increases the control's size and font dynamically for better readability. That method is detailed in the extended cut of the zoom box tutorial I referenced at the beginning.

If you are enjoying these development tricks and want to learn more VBA to unlock even more powerful features for your databases, check out my developer courses for additional tips and techniques.

You can find a complete video tutorial with step-by-step instructions on everything discussed here on my website at the link below.

Live long and prosper, my friends.
Topic List Using VBA to open the Zoom box on field click
Accessing control properties and events
Adding code to a field's On Click event
Using DoCmd.RunCommand acCmdZoomBox
Creating a Zoom button on a form
Setting focus to a control with SetFocus
Combining SetFocus with the Zoom command
Making a Zoom button work for any field
Using Screen.PreviousControl.SetFocus
Basic error handling with On Error Resume Next
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/9/2026 2:57:15 PM. PLT: 2s
Keywords: TechHelp Access, zoom box vba, pop up zoom window, vba on click event, zoom on field click, acCmdZoomBox, single line vba, open zoom box, setfocus vba, previouscontrol setfocus, debug compile vba, zoom via button, zoom box command, enlarge field vba, erro  PermaLink  Zoom on Click in Microsoft Access