How to Hide/Show a Ribbon Menu: MS Access
MS Access 2010 has a big stripe of a Menu and command icon for each menu called “Ribbon Menu.” Many menu commands and icons are used for the developer and not needed for the regular users. We can hide those menu and icons by using the Docmd command in the VBA code.
Example of MS Access Ribbon Menu
Example of Access Ribbon Menu is hidden
Put VBA code under the On Load Event Procedure on the Navigation Form (first form opened).
Hide Ribbon Menu with code:
Private Sub Form_Load() DoCmd.ShowToolbar "Ribbon", acToolbarNo End Sub
Show the Ribbon Menu again with code:
Private Sub Form_Load() DoCmd.ShowToolbar "Ribbon", acToolbarYes End Sub
Report without Ribbon menu
When the Ribbon menu bar is hidden at the beginning of Navigation form opened. The Ribbon menu will stay hidden until program closed. When the report is opened then we will not able to see the report toolbar for any action such as print icon or close icon.
In order to see a Ribbon menu bar again, we need to activate/show a Ribbon menu again when open report with the code below.
Insert the code below into the On Load Event Procedure, On Open Event Procedure and On Close Event Procedure as shown in the picture below:
Private Sub Report_Load() On Error Resume Next ‘Show Ribbon menu when form loaded DoCmd.ShowToolbar "Ribbon", acToolbarYes End Sub
Private Sub Report_Open(Cancel As Integer) On Error Resume Next ‘Hide Navigation Form when reported is loaded Forms![Navigation Form].Visible = False DoCmd.Maximize End Sub
Private Sub Report_Close() On Error Resume Next ‘Hide Ribbon menu when form closed DoCmd.ShowToolbar "Ribbon", acToolbarNo ‘Show Navigation Form again after report is closed Forms![Navigation Form].Visible = True DoCmd.Restore End Sub
Report with Ribbon menu for Print Preview
We will able to see the report toolbar for all actions such as print icon or close icon when the report is opened. The other useful functions/icons such as view page, page layout or export data to Excel, Text or PDF file are included on the Ribbon menu.