Default Button
By Richard Rost
2 years ago
Press Default Button with Enter Key in MS Access
In this Microsoft Access tutorial, you will learn how to create a default button to quickly move to a new record, streamlining data entry and improving form navigation without the need for a mouse.
Laurel from Kirkland, Washington (a Silver Member) asks: I've got a data entry form where I enter a bunch of customer information, but there are a ton of fields on it, and sometimes I only have to enter a few things. I'd like to skip the next 50 or so fields. Is there a way I can move to a new blank record without having to stop and grab my mouse? I've looked for a keyboard shortcut, but I can't find one.
Members
There is no extended cut, but here is the database 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
Keywords
TechHelp Access, Default button, Enter key, Access beginner class, Form navigation, data entry efficiency, Record Operations, Add New Record, Default property, Default property, Cancel property, Form Operations, Close Form, Tab Order, macro editing, VBA programming
Subscribe to Default Button
Get notifications when this page is updated
Intro In this video, I will show you how to set up a default button on your Microsoft Access form, allowing you to press Enter to trigger a button action no matter where you are on the form. I will also talk about creating a cancel button that can be triggered with the Escape key. You will learn how to assign keyboard shortcuts to buttons, use the button wizard to add a "new record" button, and make simple edits to the button's macro to streamline your data entry process.Transcript Today, I'm going to show you how to create a default button, how to press a button on your form by using the Enter key, so you can create a button on your form, and no matter where you are in the form, any other field you press Enter, and it pushes that button. That's called a default button. I'm also going to show you how to create a cancel button which you can press Escape to get.
Today's question comes from Laurel in Kirkland, Washington, one of my Silver members. Laurel says, "I've got a data entry form where I enter a bunch of customer information, but there are a ton of fields on it, and sometimes I only have to enter a few things. I'd like to skip the next 50 or so fields. Wow, 50, that's a lot. Is there any way I can move to a blank new record without having to stop and grab my mouse? I've looked for a keyboard shortcut but I can't find one."
Well, first, there is a keyboard shortcut you can use to move up and down through records, but if you're like me, I can never remember those keyboard shortcuts unless I use them all the time. In fact, I tried doing a video series on keyboard shortcuts, but even I don't remember them all, so I kind of stopped doing that. But let's say you're in your database; this is my TechHelp free template. You can get a free copy off the summer website if you want to, and let's say this is your customer form. Okay, you know what? To stop and hear a fill out, let's expect, let's just simplify this a little bit; I'm going to delete all of this stuff. I was to make this nice and easy. And let's say that you have thought, you know, you got all this information you can enter, but let's say you just did a trade show and you're literally just running down typing in the first name, last name, email, next, first name, last name, email, next, and so on.
Now the first thing I'm going to say is you could just build a simple little continuous form, like this guy that's got just the fields you need. You go first name, last name, email, done. Next record, first name, last name, email, done. But, if you still want to work with this form, we can do that. Now, the keyboard shortcut that I mentioned a minute ago, you can go Control-Page Up and Control-Page Down to move through records, if you want to remember that. So, if you're on the last record and you're typing something in, typing in another person, if you press Control-Page Up, it's going to move to the next blank record. So that's one thing you can do. Plus, if you're working with other end users, you got a bunch of people doing data entry for you, they're not going to remember the keyboard shortcut. So, let's give them a button that they can have right here.
Okay, so Design View, we're going to make a button. And all that button is going to do is go to a new blank record. Because if you're in the middle of entering a record and you move to a new blank record, it's going to save that record. A lot of newbies think that you got to find a save button or something. In fact, I got a whole separate video on that. Because some people get confused. They think it's like Excel where if you don't save the file, then you lose the information. But no, in Access, if you type in a bunch of stuff and you go to another record, that stuff is saved. So, and that's kind of a training issue. All right? So, let's go grab a button. We'll drop a button right down here. Now we can use the wizard for this button.
All right? We're going to come down here to Record Operations and then Add New Record. Next, let's put the text in there. I like to use text because again, a lot of people don't know what these, what does a pencil mean. Next, give it a name, we'll just call it AddBtn, and then finish. Now here's your add record button. Okay, save it, close it, open it, and now as you type in, you'll eventually get down to that button, okay and then you can push the space bar or the enter key on that button. But like you said, you don't necessarily want to have to tab all the way down to that or grab the mouse. I know me, when I'm doing data entry, I don't like this, you know, I'm typing, typing, typing, I don't want to have to stop, grab the mouse, find the button. So we can do two things that will allow us to push this button no matter where we are in the form.
The first thing is to use an Alt keyboard shortcut. So you go right in front of whatever letter you want to make the shortcut and put an ampersand there, all right, like ampersand A. Hit Enter. Now you'll see this little underline under that A, okay? Save it, close it, open it. Oh, wrong one. Now you'll see whenever, wherever you are on this form, all right, you can press Alt A and it will push that button. Okay, it will move you to a blank new record. Now the focus is still on the button. You can see the dots around it. So you got to press Tab and that will move you back up to the first name field. You can type someone else in, blah, blah, blah, blah, blah, Alt A, next record.
Okay, want something even simpler than that? Well, we can make that the default button. Every form can have one and only one default button. Open up this guy's properties, double-click on it, go to Other, and you'll see Default and Cancel. Default is the button that gets pressed whenever you press Enter on the form, okay, unless you're in a notes field like a long text field, okay, then Enter gives you a new line. Or if you're on another button, if you're sitting on another button, it'll push that button. So as long as you're in a regular text field, set Default to Yes and now save it, close it, open it, go to a new record. I could be right in here typing blah, blah, blah, blah, blah, blah, blah, blah, and press Enter, boom, new record, and again you gotta press Tab, and you're right back there on the next record, ready to go. Okay? So you can press Alt A, or now you can press Enter anywhere on that form.
There's also a Cancel button. Let's say you want to make another button to close the form. All right, Design View. Let's set up the button first. So go to Buttons, drop it down here. We're going to go to Form Operations. And by the way, I cover all of these different command button wizards in my Beginner course. Well, most of them. Most of them I cover in the Beginner course, a couple more in the Expert course. Some of them are a little more advanced. But Form Operations, Close Form, next. I like text. The stop sign is pretty straightforward. You can use that too. Oh, this used to actually be a little stop sign. They changed that. I forgot about that. Next, Close Form, Next. All right, Close button. Now we got a Close Form now. We can do the same thing. We could do like Alt F for this one. Right, Alt F will now close that form, and you can pick any letter you want in here. Only one letter per form, by the way. Okay, and you can also make this the cancel button.
So now save it, close it, open it. If I'm sitting here, if I press Alt F, It closes that form. Or if I'm sitting here, and I press Escape, I'm going to hit Escape on my keyboard, it closes the form. That's the Cancel button. All right, so now you want to, you know, start going to town, you hit Alt A, Go to a blank new record, tab up to the first name. Oh, I got a hit tab now. I'm going over here, right? Why is that? Well, because I just added this button. So now if I hit Add Record, the focus is here. If I hit Tab, it goes to the next field. Tab again, it goes up top here. Now there are a couple of things you can do. You can take both of these buttons out of the Tab Stop if you want to, which is literally just select both of them, find the Tab Stop property, and set that to no. But now you can't tab to that button either, so keep that in mind. Okay, or you can just change the Tab Order if you want to. Again, I got videos on Tab Stops and Tab Orders as well. I'll put a link down below.
But what you can also do is if you want to edit the macro in that button, you can make it so that when you click the button, it goes up to the first name field. You want to see how to do that? A little bonus material for you. You ready? We're going to break past the beginner stuff real quick. I'm going to show you a little bit of extra stuff. Usually, I cover editing macros in my advanced classes, but it's real super simple. Watch this.
All right, so when we create a button with the wizard, it creates a macro in the button. And you can see that if you click over here on the Event tab, you'll see Embedded Macro. Okay, or you can just right-click on this button and go to Build Event, which is just off the screen here. Let me move that up a little bit. Right-click and then Build Event. That will open up this Macro Builder. All right. Let me maximize this, so you can see. These are easier to work with if you maximize. All right. So there's some stuff in here you don't got to worry about. There's an on-error clause. We don't need to worry about that. Then there's Go To Record. This guy does the work. It goes to a new record, okay, which is what the button does. Okay. Then you got some error handling here. Don't worry about that; ignore that. Okay, so we're going to go to a new record and then when we're done going to a new record, we're going to go to a control. Text boxes, command buttons, those things are all called controls. So open this up and look for the command, Go To Control. Okay, now, what's the control name? Where do you want to jump to? I'm going to jump to the first name field. So type in First Name, and there it is right there; it comes right up for you. First Name. Okay, save it, close it, now we're back to our form, I'm going to restore that to a normal size form, let's close the form, save it, open it back up again, and now watch what happens if I hit Alt A, boom, it goes to the new record and puts the focus on the first name control.
And that's just a little teeny, teeny, tiny bit of macro editing and I cover macros in detail in my advanced classes. You can either use macros or VBA programming or both. I teach them both. In my developer classes, I teach VBA programming. I prefer VBA programming myself. It's got a lot more flexibility.
If you like this stuff, if you like learning with me, I got tons of lessons available. My Access Beginner 1 class is free. It's about four hours long. It teaches you all the basics right now. I got nine levels, fourteen hours of additional beginner lessons where we go through things like that Command Button Wizard, all kinds of cool wizards in there, then after that we graduate to the Expert lessons. I got thirty-two levels of those. We cover all kinds of relationships, action queries, you name it. In the advanced levels cover macros, which is why should you tiny bit of today and the my developer lessons, we cover programming, all kinds of advanced developer type stuff. Plus, I got lots of seminars and templates and you name it, all kinds of stuff on my website. Check it out. I'll put links down below for all this stuff.
But there you go. That's going to be your TechHelp video for today. I hope you learned something. Live long and prosper, my friends. I'll see you next time.Quiz Q1. What is the key benefit of setting up a default button on a Microsoft Access form? A. It allows a button to be pressed using the Enter key from anywhere on the form B. It colors the button red so it stands out to the user C. It disables other buttons on the form so only one can be clicked D. It requires users to use the mouse to activate the button
Q2. Which keyboard shortcut can be used to move to a new blank record in Access forms, according to the video? A. Alt-Enter B. Control-Page Down C. Shift-Tab D. F2
Q3. What is the main purpose of a Cancel button on an Access form? A. To delete the current record B. To close the form, often by pressing the Escape key C. To print the form contents D. To validate the form fields
Q4. What must be TRUE about a default button on a form? A. There can be only one default button per form B. Every button on the form can be set as default C. Default buttons are only available in Reports D. Default buttons are only available for admin users
Q5. How can you assign a keyboard shortcut (such as Alt-A) to a command button in Access? A. Name the button starting with "Alt" B. Add an ampersand (&) before the desired letter in the button's text C. Set the Shortcut property to True D. Write a macro to listen for key presses
Q6. What is the effect of removing command buttons from the Tab Stop property in the form design? A. The button is deleted from the form B. The button cannot be selected or activated at all C. The button cannot be reached by pressing Tab when navigating the form fields D. The button is invisible to users
Q7. When you move to a new record in Access by clicking a button created by the wizard, what happens to data in the current record? A. It is lost unless you have a manual save button B. It is automatically saved by Access C. It is only saved if you press Control-S D. It is discarded when you move back
Q8. What extra step can you add to a macro in a button to improve data entry efficiency? A. Set the focus to the first field (like First Name) after moving to a new record B. Print the record automatically C. Export the data to Excel D. Lock all the fields except the button
Q9. If you want Enter to trigger a button from anywhere on the form (except in a notes field), what property should you set? A. Enabled: No B. Default: Yes C. Cancel: Yes D. Visible: No
Q10. What does setting the "Cancel" property to Yes on a button allow? A. Users can use the Enter key for this button B. The button will be pressed when the Escape key is used C. The button deletes the current record D. The button automatically saves the form
Answers: 1-A; 2-B; 3-B; 4-A; 5-B; 6-C; 7-B; 8-A; 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.Summary Today's TechHelp tutorial from Access Learning Zone is about setting up default and cancel buttons on your Microsoft Access forms, and how to trigger actions using the Enter and Escape keys. I will also answer a question about quickly moving to a new blank record in a data entry form with many fields, especially when you need to skip a large number of them.
Suppose you have a data entry form designed for entering customer information and you often have to skip many fields. It can be cumbersome if you have to grab the mouse or tab dozens of times just to add a new record and keep working efficiently. While there are keyboard shortcuts in Access for moving through records, such as Control-Page Up and Control-Page Down, these can be hard to remember and even harder for other people who might be using your database. That is why adding dedicated command buttons can really help.
First, consider simplifying your data entry process by building a minimal form that only contains the fields you actually need. For repeated tasks like entering names and emails after a trade show, a streamlined form can save a lot of time. However, you might want to keep working with your existing, more complex form. In that case, a practical solution is to add a button that moves you directly to a new blank record.
To do this, go into Design View for the form and add a button. The Command Button Wizard will prompt you to choose an action, and you can pick Add New Record under Record Operations. I recommend labeling the button clearly with text instead of just an icon, as not everyone recognizes the standard images. Give the button a sensible name for reference.
Now, although you can use the mouse or tab down to reach this button, it is much more convenient to trigger it using the keyboard. You can assign an Alt keyboard shortcut by adding an ampersand before the letter you would like to use in the button text (for example, ampersand A), and now pressing Alt-A anywhere on the form will activate the button and move you to a new blank record. After the new record is added, the focus stays on the button, so you need to press Tab to get back to your first field for data entry.
An even better solution is to set this as your form's default button. Every form in Access can only have one default button at a time. In the button properties, on the Other tab, you can set Default to Yes. With this enabled, pressing the Enter key anywhere in a standard text field on the form (not in a long text or notes field, and not while on another button) will activate this button. This saves you from having to use the mouse or remember obscure keyboard shortcuts.
You can also create a cancel button that closes the form when the Escape key is pressed. Again in Design View, use the button wizard and pick Close Form under Form Operations. Set the text label and assign an Alt key if desired. In the properties, set Cancel to Yes. Now, pressing the Escape key immediately closes the form.
If you want to further streamline the process, you can make it so that after adding a new record, the focus automatically returns to your first input field (such as First Name) so you can continue entering data without having to Tab back up. This requires a minor edit to the macro created by the Command Button Wizard. In the property sheet under the Event tab, select the button's Embedded Macro and open it in the Macro Builder. You'll see instructions such as Go To Record to add a new record. You can add another command, Go To Control, and specify the name of the first input field. Now, when the button (or keyboard shortcut) is pressed, Access not only creates a new record but also places the cursor right on the field where you can start entering information again.
If you find yourself wanting even more customization, you can look into VBA programming, which offers advanced flexibility, or learn more about working with macros. I teach all of this in depth in my advanced and developer-level courses.
To sum up, you can move to a new blank record in your form using custom buttons with keyboard shortcuts, set up default and cancel buttons to work with Enter and Escape keys, and even control where the cursor lands after an action by editing simple macros. All of these features help make data entry smoother and more efficient for you and anyone else using your database.
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 Creating a default button on an Access form Setting up a button to move to a new blank record Using Control Page Up and Control Page Down for record navigation Adding a command button with the wizard to add new records Assigning keyboard shortcuts to buttons with ampersand Making a button the default button to trigger with Enter Understanding Enter and the default button in different field types Creating a Cancel button to close the form Assigning a keyboard shortcut to the Cancel button Setting a button as a Cancel button to trigger with Escape Adjusting Tab Stop property for buttons Editing a button's macro to set focus to a specific field Using Go To Control macro action to set focus after navigation
|