Main Menu
By Richard Rost
13 months ago
Create a Main Menu Navigation Form in MS Access
In this Microsoft Access tutorial, I will demonstrate how to create a main menu for your database using two simple methods. For beginners, we'll create straightforward buttons to navigate forms and reports. For developers, I'll introduce a list box method that dynamically pulls menu options from a table, enabling easy updates without altering the form design. We'll cover the essentials of setting up each method, including form design tweaks, adding command buttons, and utilizing list boxes for more advanced functionality. Whether you're a novice or a seasoned developer, this tutorial provides concise, practical insights for building functional main menus in Access.
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
Keywords
TechHelp Access, main menu design, buttons for beginners, list box for developers, dynamic menu from table, command button wizard, form design basics, list box setup, VBA list box events, On Double Click event, table-driven menus, open forms with buttons, open reports with buttons, Access navigation menus, customizable menus, unbound form properties, list box properties, debug compile VBA, conditional VBA statements, Access menu layout, single-click versus double-click, manage reports in Access
Subscribe to Main Menu
Get notifications when this page is updated
Intro In this video, I will show you how to create a main menu for your Microsoft Access database using two different methods. First, we'll cover a beginner-friendly approach with simple buttons that open forms and reports. Then, I'll walk you through a more advanced method for developers, where you'll build a dynamic menu using a list box that pulls its options from a table and uses VBA to open objects. We'll also look at customizing your menu form, adjusting form properties, and setting up a secondary menu for more complex needs.Transcript In today's video, I'm going to show you how to make a main menu for your Access database. I'm going to show you two methods: one for beginners, which is just some nice easy buttons, and then another method for developers, where we'll make a list box that's pulled from a table. All you have to do to update your menu is just update the table. So we're going to cover both of those real quick in today's video.
Now, I've got several other videos where I go about all the different kinds of ways you can make menus. You can use switchboards, you can use navigation forms, and I also show you how to make the quick buttons. But lots of people constantly ask me this, and people don't want to sit through a long video to learn how to do this. So I'm going to show you real quick how to do it.
Here's my TechHelp free template. In here, I built this simple main menu that's got a couple of buttons. You click on a button, and it opens a form. You click on a button, and it opens a report.
How do I do that? Well, I'm going to close this guy. We're going to start from scratch. We're going to go to Create and then Form Design. This guy, a big blank form. I like to start off by giving the form some color. So we'll pick format and maybe give this guy a green background. If you want to put a label across the top, you can, Form Design, grab a label, make a nice big main menu across the top here. Give it some color and you can do all this and play with the different settings and make it white and do whatever you want, make it giant.
So there's your main menu label, and you can make it pretty. I'm just showing you the quick and dirty. Now, to get the buttons on here to open forms, you go to Form Design, you hit the Command Button, you drop it right there. A wizard's going to start up. You pick Form Operations, open a form, hit next, pick the form you want to open like Customer Form, hit next, you want to find specific records or show all the records. We'll just pick all the records. I covered this other option in my other video. I'll give you a link to all that down below.
So we're just going to show all the records. Hit next, give it text or a picture, whichever you want. I'm going to put in here "Customer Form" or "Customers" or whatever you want it to say. Next, give it a name. I like to call it something like "Customer Form Button" or whatever, but that's optional. You don't have to give it a meaningful name, and then hit finish.
And there you go. There's your real simple button that opens that form. Now, I'm going to save it, Control S, we're going to call this my Main Menu. I'm going to call it Main Menu 2 because I already have a main menu, Main Menu 2F. Hit okay, I like to end all my forms with the letter F. Close it, and now when I open up my Main Menu 2, there it is. Click a button and there's a customer form. It's that simple.
Same thing for reports. Go to Design View, Command Button, drop a button underneath it. Go to Report Operations, preview a report. Make sure you pick "Preview." If you don't pick "Preview," it's going to spit right out on your printer. I like to pick "Preview." Next, pick a report. I'll use my Customer R. Text, "Customer Report." Give it a meaningful name, "Customer R Button," and then finish. There's your customer report button, and you can spend your time making these buttons look pretty and whatever else you want to do. Save it, close it, open it, click it, and there's your report. See that? Real simple, not that hard to do. You can put as many buttons on here as you want.
I've got some pretty complicated menus I've designed. In my Access Beginner Level 7 class, I show you a lot more detail on how to build these crazy-looking menus with all kinds of stuff on them. I'll put a link to that down below.
Now, there are some other things I like to change. For example, this is what's called an unbound form. It's not bound to a table. This is a bound form. It means it's got fields in it that pull off the customer table. You need the Record Selector; you need the Navigation Buttons. You don't need those on a menu form. So I'm going to right-click, Design View, I'm going to pull up the form's properties by double-clicking on that box right there. Go to Format and then we're going to turn off some stuff.
Record Selectors, we don't need those. Navigation Buttons, we don't need those. Scroll Bars, we don't need those. And you can turn off other things like the Control Box, the Maximize Minimize buttons, anything else you feel like you don't need. Save it, and while I'm at it, I'm going to resize this guy just a little bit. We're going to do that and we're going to come over here and do this. Doesn't need to be that big. Save it, close it, open it, now it's starting to look more like a menu. Maybe give it a caption. Click, Design View, back to the properties, Format, Caption, Main Menu. Save it, close it, open it, there you go.
Want to make a secondary menu under that one? Sure, do the same exact thing and just make one of these buttons open up the other menu. Let's pretend that this is a secondary menu. Design View, button over here, Form Operations, open a form, next, where's my first main menu, next, we'll call this the second level menu or whatever you want to call it. Next, maybe this is like the administrators menu or whatever, Menu 2 Button. Okay, and now this is the button that will open up the second level menu. We'll put it down here. We'll slide this over like that. Save it, close it, and now I'll open up this guy, that's my Main Menu, and then click and it opens up my secondary menu. Slide it over here, maybe. Hit Control S to save it, it should save it in that spot. Newer versions of Access are pretty good about this; older versions of Access, it lost the form positioning a lot. The secondary menu could have other stuff on it.
That's the basics, the basic part of how to make a main menu. I didn't have to sit through a 20-minute video, you got it in three. That's going to do it for the beginner portion of this video. Beginners, you're done. Bye, see you, get out of here. Developers, we're up. If you're not a developer and you want to be, if you want to learn this crazy VBA stuff all the cool kids are talking about, go watch my intro to VBA video. It's about 20 minutes long, it'll teach you everything you need to know to get started, and we're going to do some pretty cool stuff with just a little tiny bit of VBA. You ready?
This menu is nice and all, but every time you want to add a button or change things or whatever, you've got to go into the form design and blah, blah, blah. Wouldn't it be nice if you could just change the menu with data from a table, so you didn't really have to make design changes to the database? Well, you can. Let's go back to my stock main menu here. I'm going to go into here, design view. I'm going to delete all these buttons. Goodbye. We're going to replace it with a list box. Now, the list box needs some place to get its data from. So let's create a table, Create, Table Design. I'm going to call this the Menu Table. Or excuse me, this should be the Menu ID. It's the Menu Table, but the Menu ID goes first. How about a description? How about the object name, right, what object are you opening, form, or report, and then a sort order? Where do you want it in that list? You know, one, two, three, four, and so on. Save this as the Menu Table, Menu T, autonumber, up, primary key. Let's put some stuff in here. Let me make this a little bigger.
You just put this stuff in here in the order you want it. Let's start off with my Customer List. That'll be the Customer List, F. We'll make that the first item. The Customer Form can go next, Customer F. That's two. What else we got? In here we got, the contact form. Contact F or contact form, contact F, and that'll be number three. We've got the customers with contacts form. That's Customer Contact F, that'll be number four. We'll do the orders, Order F, and then we'll do a report. I think you have a Customer Report here. Yeah, Customer Report, Customer R. Notice my naming conventions are important here because if you've been a good little Access developer and you followed me since Access Beginner Level 1, you know that I end all of my forms in an F and all of my reports in an R. There are many, many reasons why I do that. I talk about them in detail in my full course, but this is one of them. I can tell what kind of object that is just by looking at its name. If you don't do this, you'll need another field in here. You could put either an F or an R in there, one or a zero or whatever you want to indicate what type of object this is. But since I have a good naming convention, I can tell from the object name. Save that. Now that we've got our Menu Table, we can make a list box.
Form Design, find list boxes right there. We're going to drag it right here. Get the values from a table or query. Yep, that's going to be the Menu T. Yep, bring over all the fields. Next, what do you want to sort it by? My custom sort order. Next, now here's the columns look like the key column is hidden. That's fine. That's column zero. Remember that. Column one is my description. That's the only column that I want to be visible. Column two has the object name in it. We need that so we know what we're opening. So let's hide that. The sort order, I need that also, otherwise the list box can't properly sort it, which is kind of silly, but that's how it works. We also don't want to see that. So I'm going to make the width of that zero as well. So we don't see those in the box. Okay, you with me? Next, what description do you want? We're going to delete it anyways and then hit finish.
Here's the list box. There's a little label that comes with it. We're going to delete that. Goodbye. This is going to be our menu. I'm going to put it here. I'm going to make it a little wider. I'm going to make it so the background is maybe that lighter blue. Make the text a bit bigger, maybe a 16 point. Let's give this guy a good name. Go to all here and we're going to name this MyMenuList. Okay, save it. Close it. Open it. Oh, look, that's pretty. This is a little bit too wide for that guy. So let's redesign a little bit. This stuff over here doesn't need to be this wide. You can do this. I know it makes my logo not quite centered. We can move things around. You can make it look pretty on your own. I'm just going to show you how to make it functional. Save it. Close it. Open it. Looks great.
Now, how do we get where we're going? I can click on this, but it's not doing anything. We need an On Double Click event. So when the user double-clicks on one of these, you can make it a single-click event too if you want. If you want it just to click on it once and it goes there, that's fine. I prefer a double-click event. So we're going to right-click, Design View, open up this guy's properties, go to events, find On Double Click right there. Hit the dot, dot, dot, builder button that brings up my Code Builder. There are a bunch of extra spaces in there. I'm going to get rid of that. Here we are in the Menu List Double Click event.
First thing I want to do is take a look at the object name that we're opening. Let's throw it in a variable. So dim object name as a string. We're going to set that object name string equal to the menu list dot column two, whatever's in column two. That's that object name from the list box. It's hidden. Now we got it in a variable. Now it's easier to deal with. I can say if right object name comma one equals an F, that means if the right one character is an F that I know I got a form, then do command open form object name. No quotes. Once if the right of object name comma one is an R, then do command open report object name comma. Don't forget to pick the AC preview from the list, right, AC preview. Let me show you that again, because I know it's off the bottom of the screen. Slide this up. It was object name. Then when you hit the comma, you get the IntelliSense. Make sure you pick AC preview.
Otherwise, it's not an F or an R at this point. I don't know what to do with it. So a message box, bad name, whatever you want to put in there, end if. Save it. Always a good idea to hit debug compile once in a while. Close it. Close it. Open it. Then customer form double-click, boom. There it is. Slide it over here. Close it. Contact form. Boom. There it is. Order form. Boom. Now, if you want to make changes, you can do it at the table level. You don't have to push new updates to all your front-ends, all your other users. Customer report. Boom. There it is.
There are all kinds of things you could do with this. You could have it open up other menus. You can have it cascade menus. You can have this have more menus load up inside the same list box. There are a million things. I could probably spend hours on just making cool little menus like this. If you'd like to see more of this kind of stuff, you want to see me make more cool menu stuff, post a comment down below and let me know. Of course, you know how I work. The squeaky wheel gets the grease. So if enough people are interested, I'll make more videos on it.
As far as a lot of the other things I covered in this video, like dim variables, if-then, the right function, message box, columns, all that stuff, I've got videos that cover all that stuff. Plus, I cover it in my full developer course. I'll put links to all of that stuff down below.
That's going to be your TechHelp video for today. Hope you learned something. Live long and prosper, my friends. I'll see you next time.
TOPICS: Creating a main menu with buttons Form design and customization Button to open forms Button to open reports Unbound vs. bound forms Form properties adjustments Creating a secondary menu List box menu from table data Menu table setup List box customization On Double Click event in list box VBA code for dynamic menu control Previewing reports in list box menu Debugging list box event code
COMMERCIAL: In today's video, we're going to learn how to make a main menu for your Access database. We'll start with an easy method for beginners using simple buttons, and then we'll move on to a developer-level method where we'll link a list box to a table. This allows you to update the menu just by modifying the table, making the process a breeze. I'll guide you through setting up buttons for both forms and reports and show how to enhance your menu by removing unnecessary elements and adding a personal touch. For developers, we'll cover setting up a list box from your menu table and writing simple VBA code to open forms or reports from it. 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 are the two methods for creating a main menu in an Access database mentioned in the tutorial? A. Switchboards and macros B. Easy buttons for beginners and a list box from a table for developers C. Quick buttons and navigation forms D. Navigation bar and SQL queries
Q2. What is the suggested purpose of the Record Selector, Navigation Buttons, and Scroll Bars on a menu form? A. They are essential for all form types B. They should be included for navigation purposes C. They are unnecessary and should be turned off on a menu form D. They should be minimized but not turned off
Q3. In creating a basic menu with buttons, what wizard option should be selected to open a form? A. Table Operations B. Report Operations C. Form Operations D. Query Operations
Q4. According to the tutorial, why should the "Preview" option be selected when creating a button for a report? A. It sends the report directly to a PDF file B. It prevents the report from automatically printing C. It ensures the report opens in Edit mode D. It opens the report in Design View
Q5. What is the main advantage of using a list box for menu navigation in Access as described in this video? A. It allows for real-time editing of queries through the UI B. It enables easy updates to the menu without needing design changes C. It is visually more appealing than buttons D. It automatically filters data based on user roles
Q6. How does the video suggest handling object types in a list box-driven menu? A. By adding an extra column to indicate object type B. By using different colors for different object types C. By following a naming convention with 'F' for forms and 'R' for reports D. By manual entry each time a new object is added
Q7. What key programming concept is used in the VBA code to determine if an item in the list box is a form or report? A. The Left function B. A For Loop C. A Switch Case statement D. The Right function
Q8. What function is used to open a report in preview mode using VBA? A. DoCmd.OpenForm B. DoCmd.OpenQuery C. DoCmd.OpenReport D. OpenReportPreview
Q9. What VBA event is used for interacting with the list box menu items according to the tutorial? A. On Click B. On Double Click C. On Load D. On Open
Q10. What is a common naming convention used in the video for forms and reports? A. Prefix with "frm_" and "rpt_" B. Suffix with "_tbl" and "_qry" C. Suffix with "F" and "R" D. Prefix with "obj_" for both
Answers: 1-B; 2-C; 3-C; 4-B; 5-B; 6-C; 7-D; 8-C; 9-B; 10-C
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 the Access Learning Zone will guide you through creating a main menu for your Access database. We'll explore two approaches: one designed for beginners using simple buttons, and a more advanced method for developers that involves using a list box sourced from a table. This allows you to update the menu by simply modifying the table data.
I've previously covered various ways to create menus, such as using switchboards, navigation forms, and quick buttons in other videos. However, since many people want a quick guide without a lengthy video, I'll provide a brief demonstration in this tutorial.
We'll start by building a straightforward main menu with buttons in the TechHelp free template. These buttons will open forms and reports when clicked. Let's begin from scratch by creating a new form in Design View. First, I'll add some color to the form and a label across the top for the main menu title. You can customize these settings to your liking.
To add buttons that open forms, use the Command Button tool in Form Design, and follow the wizard to configure it to open your desired form. For instance, select Form Operations, choose the form you wish to open, determine whether you want to find specific records or show all records, and then assign a suitable name to the button. Repeat these steps for reports by selecting Report Operations and choosing the Preview option to avoid printing directly.
Once you've created your buttons, tidy up your form settings by removing unnecessary features like Record Selectors, Navigation Buttons, and Scroll Bars. Resize the form as needed and adjust the caption for clarity. You can also create secondary menus linked to buttons on your main menu for added organization.
For developers, we'll tackle an alternative method using a list box that sources its data from a table, facilitating easy menu updates without altering the form design. Create a table with columns for Menu ID, Description, Object Name, and Sort Order. Fill this table with relevant entries like form and report names.
Once your table is ready, integrate a list box in your form to reference this data. Set the list box properties to display the necessary columns while hiding others. Assign this list box a suitable name for future reference.
To enable functionality, implement an On Double Click event for the list box that checks the object type using VBA. Based on whether it detects a form or report, use the open form or open report commands. If it encounters an unknown name, provide an error message.
By following these steps, you'll have a functional main menu capable of dynamic updates based on data modifications. This method avoids the need for design changes when updating your database's menu.
We'll conclude here, but if you're interested in further exploring menu functionalities or other topics discussed, feel free to comment. Additional resources related to the concepts covered can be found in my developer course linked below.
For those willing to explore the VBA coding aspects involved, I encourage watching my intro to VBA video. It covers the essentials to get you started with advanced Access 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 Creating a main menu with buttons Form design and customization Button to open forms Button to open reports Unbound vs. bound forms Form properties adjustments Creating a secondary menu List box menu from table data Menu table setup List box customization On Double Click event in list box VBA code for dynamic menu control Previewing reports in list box menu Debugging list box event code
|