|
||||||
|
Introduction Welcome! Zoom, Resize, and Error Events Welcome to Microsoft Access Developer Level 41. In this course we will address how to zoom in and out of a form in Microsoft Access, including workarounds for resizing forms and controls, using anchoring, and handling different zoom levels across form sections like headers, footers, and subforms. We will also discuss form-level error handling events, including how to add custom error messages and minimize user-unfriendly errors. This course builds on Developer Level 40 and prior Access training, and is suitable for users of most recent versions of Access. NavigationKeywordsAccess Developer, zoom form, resize controls, form anchoring, adjust font size, zoom function, public function, max zoom, min zoom, form sections, form header, form footer, subforms, recursion, on activate event, form error events, custom error message
IntroWelcome to Microsoft Access Developer Level 41. In this course we will address how to zoom in and out of a form in Microsoft Access, including workarounds for resizing forms and controls, using anchoring, and handling different zoom levels across form sections like headers, footers, and subforms. We will also discuss form-level error handling events, including how to add custom error messages and minimize user-unfriendly errors. This course builds on Developer Level 40 and prior Access training, and is suitable for users of most recent versions of Access.TranscriptWelcome to Microsoft Access Developer Level 41 brought to you by accesslearningzone.com. I am your instructor Richard Rost.Today's class focuses on zooming in and out of a form. This is one of the major complaints that people always have when it comes to Access. In other applications like Word and Excel, you can zoom in and out. You can make the document bigger, the spreadsheet smaller, or whatever. You cannot do that in Access. In today's class, we will see how you can do that, kind of. We will show you some really cool tricks. We are going to learn about form-level error handling events. You can have events that cover the whole form and can take care of different error responses. You can get rid of some of those built-in, user-unfriendly error messages. This class follows Access Developer Level 40. I strongly recommend you have finished all of my previous classes - Beginner, Expert, Advanced, and Developer levels - before continuing with today's class. My lessons really are designed to be followed one after the other, so do not skip levels. See this page for details. This class is recorded with Microsoft Access as part of a Microsoft 365 subscription, which I strongly recommend. It is currently 2022. If you are using the retail version, this is roughly equivalent to Access 2021. However, the lessons covered in today's class should work with any version of Access going back to 2007. If you have any questions regarding the material covered in today's class, just scroll down to the bottom of the page that you are on and post your questions there. Take a minute to read through any other questions that may have been posted, as your question may have already been answered. Also, make sure you click on the red subscribe button to get notified if any other questions or comments are posted for this class. Also, make sure you visit the Access Forum on my website if you have any questions about Access in general. Let's take a closer look at exactly what is covered in today's class. In Lesson One, we will begin by learning about anchoring, which is a technique that allows you to resize the controls, like the text boxes on your form. People with different screen sizes can stretch the form and have bigger text boxes. You can also anchor buttons so they stay in the bottom right corner. For example, as the form gets bigger, those buttons move. That is all covered in Lesson One. In Lesson Two, we will learn how to actually zoom in and out of forms by making the controls, the forms themselves, and the fonts larger and smaller. In Lesson Three, we are continuing to work with zoom levels. We are going to make form zoom a public level function so we can call it from any form in the database. We will set maximum and minimum zoom levels so the user cannot zoom in too far or out too far. In Lesson Four, we are going to continue and finish with zoom levels. We are going to deal with different sections on the form, like the form header and form footer. Those have to grow and shrink too. We will deal with subforms. Not only do you have to grow and shrink the subform control, but you have to handle all of the objects inside that control, which is another form. This means we have to learn recursion, which is having the zoom function call itself. That is pretty cool. Then we will learn the on activate event, which I did cover briefly back in Access Advanced One, way, way back, forty-some lessons ago. That is what happens when you jump from form to form. There is a lot of cool stuff in Lesson Four. In Lesson Five, we are going to learn about form on error events. This is an event handler that happens before a validation rule and before any control-level error handling. You can use these to put your own custom error messages there instead of the unfriendly Access default error messages that sometimes pop up. QuizQ1. What is a major complaint people have about Microsoft Access forms compared to other Office applications?A. You cannot zoom in and out of forms easily B. Forms do not support text formatting C. Access does not allow saving forms D. Forms cannot include images Q2. What is "anchoring" in Microsoft Access forms? A. A technique to save data automatically B. A way to resize controls as the form size changes C. A method to encrypt database fields D. A way to sort records in order Q3. What is the purpose of making form zoom a public level function? A. To allow the function to be called from any form in the database B. To hide the function from users C. To prevent any changes to the form size D. To set user permissions for forms Q4. Why would you want to set maximum and minimum zoom levels on a form? A. To prevent users from saving the form B. To ensure users cannot zoom in or out too far C. To stop users from filtering data D. To disable resizing controls Q5. Why do you need to learn recursion when dealing with zoom levels and subforms? A. To sort records in the subform alphabetically B. To make the zoom function apply to the entire database C. To handle zooming for objects within nested subforms D. To validate user inputs automatically Q6. What is the "on activate" event in Microsoft Access forms? A. It runs when the form is first created B. It occurs when switching from one form to another C. It triggers when a record is deleted D. It automates data backups Q7. What is a benefit of using form-level error handling events? A. You can remove all built-in validations B. You can provide user-friendly custom error messages C. It disables editing on the form D. It adds password protection to the form Q8. In Lesson Four, what special form sections must also be managed when zooming? A. Only the detail section B. Only the navigation pane C. Both the form header and form footer D. Only the status bar Q9. What happens if you use the default Access error messages for forms? A. Users always understand the error right away B. The messages are sometimes unfriendly or unclear C. All errors are automatically fixed D. No errors will appear Q10. What is the recommended prerequisite before taking Developer Level 41? A. Take Excel courses B. Complete all previous Beginner, Expert, Advanced, and Developer levels C. Watch random Access tutorials online D. Upgrade to the latest hardware Answers: 1-A; 2-B; 3-A; 4-B; 5-C; 6-B; 7-B; 8-C; 9-B; 10-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. SummaryToday's video from Access Learning Zone focuses on Microsoft Access Developer Level 41. I am your instructor Richard Rost. In this class, our primary topic is zooming in and out of a form, which is a feature many Access users have wished for. While applications like Word and Excel allow you to easily zoom your document or spreadsheet, Access does not come with built-in zoom functionality for forms. Today we will cover some creative ways to achieve this effect.We will also explore how to handle form-level errors. Access sometimes displays unfriendly system error messages, but with form-level events, you can add your own handling to show more user-friendly responses. We will look at how to catch and respond to these errors throughout your entire form. This class builds directly on what was covered in Access Developer Level 40. If you have not completed my earlier classes, including the Beginner, Expert, Advanced, and Developer series, I strongly suggest you work through all of them before continuing here. Each lesson is designed to build on previous topics, so you will get the most benefit by following them in order. For this series, I am using the Microsoft 365 subscription version of Access, which I highly recommend. I recorded this class in 2022, so if you are using the retail version, what you see should be roughly the same as Access 2021. In fact, most of what I cover today will work with any version of Access going back to 2007. If any part of the material covered in this class is unclear, I encourage you to post your questions in the comments section at the bottom of the page. Please check through any existing questions and answers first, as many common issues may have already been addressed. Also, be sure to click the red subscribe button so you get notified of any new questions or replies related to this class. If you have more general Access questions, you can always visit the Access Forum on my website. Now, let's go over the specific topics in this class. In Lesson One, we will talk about anchoring controls on your forms. This lets you make things like text boxes automatically resize when the form itself is resized. For example, if someone has a different screen size or resolution, the controls on your form will adjust in size. You can also anchor buttons so they stick to the bottom right corner, moving with the form as it grows or shrinks. Lesson Two covers how to zoom in and out of forms by changing the sizes of controls, the form itself, and the fonts. This is not a native feature in Access, but I will show you some techniques to simulate zoom functionality. In Lesson Three, we will expand on this by making the zoom functionality a public function that you can call from any form in your database. We will add maximum and minimum zoom levels, making sure users cannot zoom in or out beyond a certain point. Lesson Four takes this even further. We will address the need to resize form sections, such as headers and footers, when the zoom level changes. We will also look at handling subforms. Since a subform is really a form within a form, not only do you need to resize the container but also the controls inside it. To do this, we will need to use recursion, which allows the zoom function to call itself and process all nested forms properly. We will also discuss the on activate event, which fires when switching between forms. This event gives you a lot of flexibility as users navigate your database. Finally, in Lesson Five, we will dive into form on error events. This event fires before a validation rule or control-level error handling takes place. You can use this to display your own custom error messages instead of the default Access ones, which are often confusing to users. For a complete video tutorial with step-by-step instructions on everything discussed here, visit my website at the link below. Live long and prosper, my friends. Topic ListAnchoring controls for form resizingResizing text boxes and buttons with form size Anchoring buttons to stay in position Zooming in and out of Access forms Changing font sizes on forms Adjusting control sizes with zoom Creating a public form zoom function Setting maximum and minimum zoom levels Handling zoom for form headers and footers Dealing with subforms when zooming Recursion for zooming controls in subforms Using the Form On Activate event Form-level error handling events Customizing error messages with On Error event ArticleOne of the most common requests I hear from Microsoft Access users is the ability to zoom in and out of forms. In programs like Word and Excel, zooming is simple and built in, but Access does not offer this feature natively. However, with a little creativity and some VBA programming, you can add your own zoom functionality to Access forms, making them easier to read and use across different devices and screen sizes. In this article, I will show you step by step how to achieve zooming inside your Access forms, along with some additional techniques to improve usability, like anchoring controls and handling form-level errors.Before we get into zooming, let us talk about anchoring. Anchoring is a powerful feature in Access that lets you control how your form's controls, like text boxes and buttons, are resized as the form itself changes size. For example, you might want a button to always stay in the bottom right corner even as the user stretches the window, or you might want your text boxes to grow horizontally as the form gets wider. To set anchoring, go into your form's design view, select a control, and look for the Anchoring property. From there, you can choose options like Top Left (the default), Bottom Right, Stretch Across Top, and so on. Experiment with these settings to see how they affect your layout. Anchoring makes your forms much more flexible and user friendly, especially for people using different screen sizes. Now, let us start working on zooming your forms in and out. Since Access does not provide a built-in zoom slider, we have to do this ourselves. The basic idea is to programmatically change the size of each control and their fonts whenever the user wants to zoom. For example, you can put two buttons on your form, labeled Zoom In and Zoom Out. Each time a button is clicked, your code increases or decreases the height and width of every control by a certain percentage. You will also need to adjust the FontSize property for every control so that labels and text boxes scale up or down along with their dimensions. Here is a simple example of how you might do this using VBA. Suppose you want every control to grow by 10 percent each time the user clicks Zoom In and shrink by 10 percent for Zoom Out. You can create a subroutine like this: Sub ZoomForm(frm As Form, ZoomFactor As Double) Dim ctl As Control For Each ctl In frm.Controls On Error Resume Next ctl.Width = ctl.Width * ZoomFactor ctl.Height = ctl.Height * ZoomFactor ctl.Left = ctl.Left * ZoomFactor ctl.Top = ctl.Top * ZoomFactor ctl.FontSize = ctl.FontSize * ZoomFactor On Error GoTo 0 Next ctl End Sub Then, attach this subroutine to your Zoom In and Zoom Out buttons like so: Private Sub btnZoomIn_Click() ZoomForm Me, 1.1 End Sub Private Sub btnZoomOut_Click() ZoomForm Me, 0.9 End Sub This simple code multiplies each dimension and the font size by the factor you provide. If you want, you can refine this further to make sure you do not zoom in or out too much by checking for minimum and maximum values. For example, you can add code to check if the new FontSize is less than 8 or more than 40, and prevent zooming beyond those limits. As you start zooming more complex forms, you will notice that sections like headers and footers need to be resized too. You can adjust the Height property of these sections in the same way as the other controls. It becomes even more interesting when you have subforms inside your main form. In that case, you should zoom not only the subform control itself but also all the controls within the subform. This is where recursion comes in handy. Recursion is when a function calls itself, in this case to zoom nested controls. Modify your ZoomForm subroutine to detect if a control is a subform, and then call ZoomForm again on that subform's form object. For example: If ctl.ControlType = acSubform Then ZoomForm ctl.Form, ZoomFactor End If This way, your zoom works on any level of nested forms. Switching gears, let us talk briefly about the On Activate event. Access forms have different events you can respond to with VBA code, and On Activate runs whenever a form becomes active, such as when the user switches between forms. You can use this event to reset zoom levels or apply any formatting you want every time a form gains focus. Finally, form-level error handling is another important skill to learn. By default, Access shows error messages that can confuse users, especially if they enter invalid data or break a validation rule. Instead, you can use the On Error event at the form level to catch those errors yourself and provide friendlier messages. For example, in your form's properties, set the On Error event to =Form_Error() and then write: Private Sub Form_Error(DataErr As Integer, Response As Integer) If DataErr = 3314 Then ' Required field not entered MsgBox "Please fill in all required fields before saving this record." Response = acDataErrContinue Else Response = acDataErrDisplay End If End Sub This intercepts the error and displays your own message instead of Access's default. You can handle other error codes similarly. To sum up, while Access does not natively support zooming like Word or Excel, you can build your own zoom features using anchoring, recursion, and some VBA code to scale your forms and controls up or down. Coupling this with form-level error handling makes your forms much more professional and user friendly. Experiment with these techniques in your own projects and you will find your Access forms become more accessible and polished across different screens and users. |
||
|
| |||
| Keywords: Access Developer, zoom form, resize controls, form anchoring, adjust font size, zoom function, public function, max zoom, min zoom, form sections, form header, form footer, subforms, recursion, on activate event, form error events, custom error message PermaLink How To Zoom Forms, Resize Controls, and Handle Form Error Events in Microsoft Access |