Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Subform Goto First Field < Bill To Ship To 3 | Subform Goto First Field 2 >
Back to Subform Goto First Field    Comments List
Pinned    Upload Images   @Reply   Bookmark    Link   Email  
Transcript
Richard Rost 
          
8 months ago
Today we're going to talk about moving between the different parts of a form with a subform. You might have a header and a footer and a bunch of other sections. Maybe the tab order isn't going exactly where you want it to go when you press that tab key. So we're going to talk about how to navigate form sections and set the focus on the first field of the first record in a subform. Even if you left that subform previously and you weren't there, I'll explain what all this means in a minute.

This is going to be both a beginner and a developer video because I'm going to start off by showing you some keyboard shortcuts you can use, which is just a training issue to learn how to navigate around using the keyboard. Then I'm going to teach you a developer means with a couple of lines of code so that if you don't feel like remembering all these keyboard shortcuts, you don't have to. You can just press the tab key and it'll go where you want it to go.

This is a question I've gotten a couple of times in different forms, but today in the forums and Antonio from Lytle, Texas. I hope I pronounced that correctly. One of my gold members posted this in the forums: you said, I've created a parent form that includes the subform when the subform contains fields in both its header and detail sections. When I tab from the parent form to the subform, it skips the header and navigates directly to the detail section of the subform. Yeah, that's kind of how it's designed. I'd like the tab order to be parent form, subform header, subform detail. Can anyone help me achieve this?

Yes, I think we can help you. And I know a couple of the guys already posted answers in the forum. There are lots of different ways to handle this. I'm going to show you two.

Before we get started, if you are a beginner and you don't care about the VB stuff, I'm going to show you a little bit later. Make sure you understand this stuff: tab order, tab stop, and tab cycle. I cover this stuff in my beginner lessons, but if you've not learned that stuff, go watch this video first and then come on back.

I'm also going to be using my TechHelp free template today. This is the video where I cover building the order entry system that I'm going to use for this example because it has a subform. These are free videos. They're on my website. They're on my YouTube channel. Go watch those and come on back.

Okay, so here I am in the TechHelp free template. This is a free database. You can download it from my website. I've got a customer form. Customers can have orders. This is a parent form with a subform in it. Now normally when you tab, tab, tab, tab, tab, tab, tab, it jumps into the subform in the first field. Now I've gotten this question in a lot of other ways. Sometimes people ask, okay, if I tab, tab, tab, tab, tab, down to here, okay, and then I come back up top to the parent form and then I tab, tab, tab, tab, tab, it returns me right to that spot that I was down here, and some people don't like that.

Right, because sometimes you may go to a new record, and usually it'll jump you back to the first one, not always. Okay, but sometimes people want to say, okay, if I'm up here and I tab, tab, tab, I want it to always return me back up to the first field. So that's another version of this question. But what Antonio is saying is he's got a header section in here. Now I have a header section. It's right there, but I just have labels in it.

Okay, so let's make this header section a little bigger, and I'm going to move my notes field up into the header. So that's going to act as like the first field. Okay, so instead of being in the footer, the notes are now in the header. And remember, if a field is in the form header or the form footer, if it's a bound field, it means it's bound to a field in your table. That means it's going to be bound to whatever record you're on in here. Right, I cover this in my invoicing video.

So if I come in here, this is the notes for the hyper drive. This is the notes. These are the notes for the phaser bank. See how that changes as I move from record to record. Right, life support notes. Okay.

Now here's the problem that Antonio is running into. You go up here, tab, tab, tab. It's on the "Is Paid" field over here in the corner. I know, not great tab order. Tab, tab. See, it comes right back down here because that's where I left off. If you're on a new record, let's go over to here. And I'm up top here, right, tab, tab, tab, tab, tab. This is right back down on the hard drive again.

So what we want to do is we want it to come here to the product notes field here, right, the notes field. All right, so first, the beginner solution. How do we do this with the keyboard with no programming required? Well, we can use the F6 key to jump between the different sections in Access. It's going to include the form view and the Access interface. It's also not the best solution, but it's the free and cheap one that requires no programming.

So if I'm up here in the parent detail section and I hit F6, it brings me down to the header of the subform. Okay, hit F6 again and now you're in the detail section of the subform, hit it again, and now you're in the footer of the subform. All right, three different sections in the subform that I have here. Now, here's where it gets tricky. From here, if you hit F6, it puts you over in the navigation pane. And if you hit F6 again, now you're up here. And if you hit F6 again, now you're down here. So the F6 isn't really the best solution.

But if like if you're here and you want to make sure you go down to the subform, right, tab, tab, tab, and you're in, okay, you're in the wrong spot, you can hit F6 and go to the detail section or shift F6 to go backwards. All right, so you've got F6, F6, shift F6, shift F6, and so on. But if you hit it too many times, you're going to end up up here. So that's not the best solution.

So let's see what the programming solution is. Now, if you've never done any VBA programming before, don't panic. It's not hard. We literally need two lines of code to do what we want to do today. And there are a couple of extra little things I might show you, but just it's not hard.

All right, so go watch this video first. It's not scary. It's about 20 minutes long. It'll teach you everything you need to know to get started. It's free. It's on my website, on my YouTube channel. Go watch this. All right.

Now, here's the logic of what we want to do. Okay. When I go from the parent form into the subform, okay, when I enter the subform, usually using the keyboard, then I want to go to the notes field. And I also want to go to the first record because I don't want to end up in the notes field for, you know, the third or fourth record from down here. Right. So if I come up here and I tab, tab, tab, tab, I want it to go straight here on the first record. That's what I want to do. Okay.

So we need two lines of code to do this. We just have to know where to put them. So let's go into design view. Let's go to the subform control. Remember, there's a box around the entire subform. That is the subform control itself. And if you double click on that box, it'll bring up the property sheet. And make sure it says property sheet subform subreport. You don't want to be inside the subform because you're going to be on one of these controls in here. It'll say text box or section.

No, I want to be on the subform control itself. All right. So make sure you're on that box. And it'll say subform subreport. Go to the event tab. There's two events in here. Okay. This is when the subform itself gets the focus. All right. If you tab into it, it's going to get the focus. So the on enter event is what we want. So click on dot dot dot that'll bring up your code builder.

All right. The first thing I'm going to do is I want to go to the first record when I tab into the subform. We're going to use the go to record command do command dot go to record. There it is. Now you can ignore, you can use the defaults for these first two things. Right. The object name, the object type. That's fine. Use the defaults. So comma, comma. And then the record we want to go to is AC first the first record in the subform. Okay.

And now the next thing I want to do is I want to put the focus on the field that I want to be on, which in this case is the notes. There are a couple of ways you can do it. You can use set focus. I'm going to use do command dot go to control. And then I want to go to the notes field. That's that simple. It's two lines of code.

Okay. All right. Save it. Always throw in a debug compile once in a while. All right. Come back over here. And now watch this tab tab tab tab tab. You can briefly see it flashes down here because it goes to the product thing, but then our code kicks in and it moves it right up here. Right. So I'll come up. Let's do one more time. Tab tab tab tab tab tab. And you're right where you want to be.

Now the next problem of course is if I hit tab here, tab tab tab tab tab, it doesn't jump between the different sections. So I can hit F6 and go down there. If I want to then tab tab tab tab tab. Or if you want to you can also say okay if I'm in here and the user hits tab, I want to jump down to the first record of the subform. How do we do that? Well that's a little more complicated. But again it's still only like three lines of code. You just have to know where to put it.

We basically have to intercept the user's keystroke and say if they're in this field and they hit the tab key, then move down to the product name field. And I'll show you how to do that. In tomorrow's class. So tune in tomorrow same bat time same bat channel. Or if you're a member you're going to watch it right now because that's one of the benefits of membership.

While you're waiting for tomorrow's video if you want to learn more about moving around in a form using go to record and go to control, I have this video go watch this is free. And of course if you like learning with me and you want to learn more about this VBA programming thing, what is this newfangled stuff the kids are doing. Well I got tons and tons of developer lessons on my website. I take you through beginner all the way to advance developer programming.

There's so much to cover there's lots of it. I've got hours and hours and hours of lessons on my website. Don't let it intimidate you. I take you through it step by step. We go with everything from multi select list boxes to getting stuff off the web to records sets to inventory. You just you name it. I've been doing this for 20 years. And this is the culmination of most of my knowledge.

So check it out on the website. There's the link right there. Tune into my part two. And that is going to be your TechHelp video for today. I hope you learned something. Live long and prosper my friends. I'll see you tomorrow for part two.

TOPICS:
Navigating form sections in Access
Setting focus on first field in a subform
Changing tab order with VBA
Keyboard shortcuts for form navigation
Using F6 key to navigate sections
Programming solution for tab order
VBA code: do command go to record
VBA code: do command go to control
Subform control event properties
On enter event for subform
Debugging and compiling VBA code

COMMERCIAL:
In today's video, we're going to learn how to navigate form sections in Access when you have a subform that includes both header and detail sections. Ever wonder why your tab order skips the header and jumps straight to the detail section? We'll show you how to set the focus correctly using both keyboard shortcuts and some simple VBA code. First, I'll demonstrate some handy keyboard techniques, then I'll show you how to programmatically ensure tabs go exactly where you want them. Whether you're a beginner or a developer, there's something for you here. You'll find the complete video on my YouTube channel and on my website at the link shown. Live long and prosper my friends.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Subform Goto First Field.
 

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/21/2025 7:52:46 PM. PLT: 1s