Access Database Deveopers Tips – Using a Tab Control to Create a Menu Screen
You can create a simple menu screen with little effort by using a combination of a tab control and some buttons. In the below example I have created a tab control with three pages (each page has buttons on them in the example but you can put whatever you want on your pages) and three buttons (“Main”, “Reports”, “Data Entry”) at the top of the form which we will use to show the appropriate page when clicked.
For each page, I change their “Name” to something a bit more sensible as we will be using this name later in some code we will write (NB I also changed the tab control name to something more appropriate, as well as the names for the buttons that I will be using). The example below shows the name I chose for the first page (“Page 1” above).
With the tab control I now change the “Style” option to “None”. This hides the page selection row from view. Obviously this means we cannot select the pages using this function now, which is why we created the three buttons at the top of the form, as we will be using them to select the pages instead.
For each of the three buttons at the top of the form, I changed their “On Click” Event to “[Event Procedure]” and press the “…” button beside this to access the VBA code.
The VBA code window should open at the buttons “_Click()” event procedure and all you need to do is adapt the code below (adjusting for the tab control name you used earlier and the page name of the page you want to display). In my example below, “tabMenu” is the Tab Control name and “pageMain” is the name of the Page I want to display.
Private Sub butMain_Click()
tabMenu.Value = pageMain.PageIndex
Now when you click on a button, the menu options will change to the appropriate tab.