Enter Instead of Tab in Microsoft Access

Richard Rost - Aug 12 - - Dev Community

Welcome to another TechHelp video brought to you by AccessLearningZone.com. I'm your instructor, Richard Rost. Today, we're going to talk about how to use the Enter key instead of the Tab key to move to the next record in Microsoft Access.

Today, I'm going to show you how to do it for beginners, and then in tomorrow's video, actually Monday's video since today is Friday, we're going to show you a developer method that's got some additional flexibility. Today's question comes from Ludwig in Dessel, Belgium, one of my Platinum members. Ludwig says, "How can I navigate through the records in a form using the Enter key instead of the Tab key? Is there a video on this possibly with some VBA code or an event procedure or something similar? My boss is acting strange again about how it goes faster with the Enter key instead of the Tab key."

Yeah, I get it. If you hit Enter, it just behaves like the Tab key does normally. Just hit Tab or Enter does the same thing. It'd be nice if the Enter key moved you down, kind of like in Excel. And you could, if you wanted, also program it to work the same way with a single form, so you hit Enter and it moves to the next record. But let's see how we can do this.

First, a couple of prerequisites. First, of course, if you're a newbie to Access and you haven't watched my Access Beginner 1 class, go watch it. It's four hours long. It's absolutely free. It covers a lot of fundamentals that you really should know. For example, you should know what command buttons are and how to use the command button wizard to create them. In fact, this video specifically teaches you how to make command buttons to navigate back and forth through the records on a form, which is kind of what we're doing today.

This video shows you how to set a default button. A default button is the button that gets clicked when you press the Enter key on your keyboard. Now, you put these two videos together and you've got the answer for today's video.

Let's start with the continuous form. So I'm going to come into here, Design View, and I'm going to go up to Form Design, grab a command button, and drop it right here so the wizard starts up. I'm going to pick Record Navigation, go to Next Record, hit Next, put some text on there. You can put Next Record on there. It's fine. You can even put "Enter" to visually tell the user, hey, if you press the Enter key, it's going to go to the next record. It's going to push this button.

Next, give it a good name. Next Record Button or something like that, and then hit Finish. So now you've got a button that will go to the next record. Save it, close it, open it back up again. And now if I click the button, you can see it moves to the next record. Even if I'm over here, hit the button, it still moves to the next record. So you can still use Tab.

Now, how do I assign this button as the button that's pressed when I push the Enter key? Well, that's what that default property is for. Back here in Design Mode, open up the properties for this button by double-clicking on it. Come over to the other tab here and look for Default. We're going to change the default to Yes. Default means when I press Enter on the keyboard anywhere on this form, unless you're in a long text field, then it pushes that button.

So let's save it, close it, open it, and now Enter, Enter, Enter, Enter, Enter. See? Tab, Tab, Tab, Tab. Enter, Enter, Enter, Enter. Nice. Easy enough. Tell the boss it's not so weird now. This will work on a single form or a continuous form. So we can copy that button. You can actually take this button and copy it. Then go over to a different form, like the regular customer form. Right-click Design View, and we can paste it right on here.

Make this a little bit bigger, and then Paste, and then bring it down here. Now, even though the button macro carries with it, because inside this button, there's something called Embedded Macro, and that will copy over with it. But you still got to open up the properties and assign this guy to be the default button on this form. Save that, close it, close it, close it. Let's open up the customer form, and now we can use Tab to move through the fields, but Enter will still move us now to the next record. See, that's pushing that button, that next record button.

Now, as far as going to the previous record, if your boss wants to go backwards, there's a couple of things you could do at the beginner level. You could make another button to move to the previous record. I mean, if he's too lazy to use these buttons down here, I guess. Then you could assign that to a keystroke, like Alt P for previous, or you could even make it the Cancel button, and he can hit Escape to go backwards, but that's kind of weird too. I like the previous button myself, so let's do another command button. Drop it down here.

Record Navigation, go to Previous Record. Previous, I'll just put P-R-E-V in there, make it small, like that. Next, and the previous record button. What we're going to do to make this assigned to a keystroke, we're going to come right in here, and we're going to put an ampersand in front of that P. Here I'll zoom in so you can see it better. See that little ampersand right in front of the P? Press Enter, and now when you do that, you get a little underscore under the P. Now this just becomes a training issue now. Just tell the boss, well, if you want to go back a record, it's Alt P. That's just the easiest way to do it.

Save it, close it, open it, and now you can go Enter, Enter, Enter, Enter, or Alt P, Alt P, Alt P, Alt P. It's up to you. You can make an Escape button too. To make an Escape button, you just go to the Properties, and under Other, you set this Cancel button to True. Then when the user presses Escape, it pushes that button. I wouldn't recommend that for just moving backwards through records, though.

Now, in Part 2, when we get to the VBA version, I'm going to teach you how to do this with events, and you can actually assign the previous button something like Shift Enter. So it would be Enter to go forward, and then Shift Enter, or Control Enter, or whatever you want, to go back a record. We'll talk about that in Part 2.

Now, there is one caveat, and I kind of mentioned it a minute ago when you're in here. If you happen to be inside of a long text field, the Enter key gives you a new line in the field, see, just like that. So your default button won't get pressed unless you tab out of there and then press Enter. Oh, even that time, I happened to be on a button because this was next in the tab order. If you're sitting on another button, like the Orders button, then you press Enter. That will take precedence, too.

What you can do in this particular case is you could say, okay, for my long text fields, instead of the Enter key behavior being new line in a field, you can change this to default. What that will do is it will make it so that if you're in here and you press Enter, it's going to fire that button's event because it'll no longer move to a new line. If you do want to go to a new line now, you have to hit Control Enter to go to a new line. Or you can open up the Zoom box, Shift F2, and now you can type in here, and this is just like a regular little word processor.

There's a lot of things you can do. There's ifs and thens and that's and buts and everything has an exception. All kinds of things you can do. But if your weird boss's primary concern is just being able to move to the next record with Enter, well, there you go. There's an easy, nice beginner fix for you with absolutely no programming.

If you do want to see how to do it with some programming, I'm going to be talking about that in Part 2. Let's see. This video goes public on Friday, August 9, 2024. On Monday, the 12th, we will talk about the VBA version, which is a little more work but a little more powerful. But I do like to give the beginners some videos too from time to time.

So that is going to be your tech help video for today. I hope you learned something. Live long and prosper, my friends. I'll see you Monday for Part 2.

For a complete video tutorial on this topic, please visit https://599cd.com/EnterInsteadOfTab

. . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player