Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Custom Menus and Tool Bars

Introduction - Access 2003.

We already had a formal introduction to Custom Tool Bar, Submenus & Shortcut Menus through the earlier posts: Animated Floating Calendar & Calendar and Toolbars. We have seen how to reference individual Button to enable/disable it based on situations that demand it.

Here, we will take a closer look at Custom Menu bars, Toolbars & Shortcut Menus. Since it is a lengthy subject we are forced to split this into 2 or 3 Posts.

MENU BARS.

Windows-based Applications have a Menu bar at the top with titles like File, Edit, View, Insert, etc. When we click on them a long list of Options like Sub-menus, Items with Description alone, or with Button Images and Description appears in a drop-down list. When we click on any of them the designated action defined on the menu option runs and we will get our work done. We can create a Custom Menu bar with our Application-specific Menu Descriptions like Data Files to open Forms linked to Tables/Queries, Reports to preview and print Reports, Utilities for other common tasks, etc., add menu items into them and assign Actions to each of them. Initially, we will concentrate on designing the Menu Bar alone. When this is understood the task of designing Toolbars and Shortcut Menus becomes easier because the approach is the same and you will be able to do it yourself with little guidance.

Customizing Toolbars.

  1. Select Customize command from Toolbars submenu of View Menu.
  2. Select New from the Toolbars Tab.
  3. Type MyMenuBar in Toolbar Name: control and click OK. The new Toolbar Item is added in the Toolbars List and a small empty Toolbar appears in the Application surface, not necessarily at the top.

    You may be wondering that we have started discussing Menu bars then why we have to deal with Toolbars. We need to create a Toolbar first and then define it as a Menu bar, that's how it goes. For Shortcut Menu, create a Toolbar and define it as a Popup Menu (Shortcut Menu). So, the starting point is Toolbar. The Toolbar's name alone will not change its class, except referencing it in programs, and we must see that the new name is not clashing with any of the other Built-in Menus. Let us define our MyMenuBar Toolbar into a real Menu bar.

  4. Click on the MyMenuBar item in the Toolbars List in the Customize Dialogue Control, if it is not already selected.
  5. Click Properties
  6. The Selected Toolbar & Toolbar Name Controls already filled with the menu name. In the Type Property drop-down list, we can see three options: Menu Bar, Toolbar & Popup(Shortcut Menu). To define our Toolbar into a Menu Bar select Menu Bar from the list.

    Leave the other properties as it is. While installing your Application for the Users you can change these properties to determine how to behave the Menu Bar. Click Close to come out of the Toolbar Properties Sheet. It is likely that the small empty toolbar that we have seen earlier while creating it, is now disappeared, and wondering where it went. To find out remove the checkmark on the MyMenuBar item in the Toolbars Tab and put the checkmark back again and repeat this process a few times in quick succession and you can see an empty Menu bar is playing hide and seek on the top. Once we have spotted our celebrity we can continue our work.

    First, we must create some meaningful menu headings with the drop-down facility where we can add our Menu Options. Click on the Commands Tab of the Customize Control. Here, we have two sets of List: Categories & Commands. In the Categories list, the File item is already selected, if it is not select it now. In the Commands list, we will be using the first two items: Custom & New for building our Menu Options. The Custom item is used for creating a single menu item with description only and New is used for creating a single option with a Button Image and Description, which can be displayed with Image only, Text only, or both. But both of these items will not work for a Drop-down List, which we see normally when we click on File, Edit, or View Menus. We have to use another control for that.

    Move the Scrollbar down in the Categories list and you will find an item called New Menu at the bottom of the list, select it. After selecting it, in the Commands list on the right side you will find a New Menu option. This Menu is a drop-down list like control. We need all these three options to build our Custom Menu Bar.

    Customizing Menu Options.

  7. Click and drag the New Menu item from the Commands window and drop it on our new empty Menu Bar. After that click on it to display a small empty dropdown control where we will be adding our menu options.
  8. Right-click on the New Menu to display the options to change its Name. Type &Main; (we need a different name in place of File we see everywhere) in place of New Menu in the Name: control and press Enter to close. The & (ampersand) symbol at the left side of the M character of the word Main enables us to select the Main Menu by using the Alt+M Keyboard shortcut instead of clicking. You can put the & symbol left side of any character in the name to use that character as a keyboard shortcut. The character that you have chosen will appear with an underline in the Menu Name. If you look at the Built-in Menu descriptions at the top you can see one character in each Menu Name is underlined. But you must be very careful while selecting the character and see that you are not setting up a clash with the built-in keyboard shortcuts.

    For example: Assume that you have given & symbol at the left side of D in Data Files Menu and you are in the database window and the Forms Tab or Report Tab is active, if you execute the Alt+D keyboard shortcut, the selected Form, Report or whatever object currently have the focus on will open up in Design View. For the safer side, we will not give the ampersand symbol in any of the other menu options for now.

    We will create three more Menu headings: Data Files, Process, Reports, Utilities (another name for Tools). Follow the same steps explained above under 8 & 9 and create the Menu Headings.

    We will mainly concentrate on Data Files, Process, and Reports options for our own program/macro-driven methods, and in Main & Utilities Menus we will copy and add some essential built-in Options.

    We will do the easier part first, adding built-in options into the Main & Utilities menu. For easy handling of our MyMenuBar, we need to push it up above the Built-in Menubar so that we can easily copy and drop (I didn't say drag and drop and you guessed it right) the Submenus or Options into our Menu. If you are not already in the Customize option select Customize from Toolbars Submenu from View Menu. We will introduce four sample options: Close, Page Setup, Print, and Exit into our Main menu from the Built-in File Menu.

    There are too many references to use for creating Custom Menus/Toolbars. The first time anything is difficult or may find too cumbersome, but further on you will find them easy and rewarding too.

    Drag-Drop Menu Items.

  9. Click on the built-in File menu to display the drop-down list. Click and hold the mouse button on the Close menu item and press the Ctrl key with the other hand. When you press the Ctrl key, a plus (+) symbol will appear next to the selection indicating that a copy of the selected option is going to be made rather than drag the option out and leave that area empty for the built-in File Menu. Now, drag the mouse up and point to the Main item of our Menu Bar to display the empty dropdown control. Drop the Close option there.
  10. Follow the same procedure for Page Setup, Print & Exit options to make a copy of each and place it one below the other, or in between wherever you prefer.

    After dropping the menu items, if you prefer to define the option as part of a Group (for example Page Setup & Print can be members of a common group) then right-click only on the top item within the group and select Begin a Group from the displayed options menu. A horizontal line will appear above the selected option.

    NB: Any changes that you have made in any of the Built-in MenuBars (for example: If you have dragged the Print option out of the File Menu rather than copying an instance of it, it will not be available in File Menu), Toolbars or Shortcut Menus can be restored to its original state. Select Menu Bars in the Toolbars tab of the customize control and click the Reset Button.

  11. Follow the same procedure to introduce two options from the built-in Tools Menu into Utilities Menu: Spelling, User and Group Accounts from Security Submenu. The User and Group Accounts option is used by Users for changing their Login Password in a secured Application.

We will continue our discussion shortly on Data Files, Process & Reports Menu options where we plan to introduce our own simple Programs & and Macros to open Forms, Reports, etc.

Share:

4 comments:

  1. [...] are two links that you can start with: http://www.msaccesstips.com/2007/07/...and-tool-bars/ http://www.learnaccessnow.com/chap19b.html can you attach the sample file converting it to Ms [...]

    ReplyDelete
  2. I am quite brand new to this kind of blog discussion stuff yet Im willing to aid and learn a lot, I really hope. Specifically in relation health and also the particular aspects of diet and in my situation physical exercise.

    At any rate, merely saying howdy and wish to get along with for some time.

    ReplyDelete
  3. i have recently ventured to learn ms access. I was v foxpro user. The environment is quite new to me but the websites like this one have helped me a lot to catch at the essential basics.
    Specially there are very useful videos at 'youtube' that help grasp basic ideas to toddle along the path of learning access with confidence.

    ReplyDelete
  4. [...] and Reports in Menu Bars and open them from there, is that right? Check the following links: Custom Menus and Toolbars Custom Menus and Toolbars-2 __________________ http://www.msaccesstips.com (Learn MS-Access [...]

    ReplyDelete

Comments subject to moderation before publishing.

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Class Module External Links Queries Array msaccess reports Accesstips WithEvents msaccess tips Downloads Objects Menus and Toolbars Collection Object MsaccessLinks Process Controls Art Work Property msaccess How Tos Combo Boxes Dictionary Object ListView Control Query VBA msaccessQuery Calculation Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes RaiseEvent Recordset Top Values Variables Wrapper Classes msaccess email progressmeter Access2007 Copy Excel Export Expression Fields Join Methods Microsoft Numbering System Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code