In this post I am going to show you how to add a customized ribbon to you Access database
so it looks like a real desktop application.
In my experience this used to be done with a main switchboard. You would control the user’s navigation
through buttons and object frames on a form. You had to program to hide and display whenever the chosen form
was opened or closed.
What makes the ribbon so nice, is that it displays over the application, and have a picturesque hierarchy of menus and sub menus to perform actions with, and it persistently stays on top of the screen.
Check out the following 2 menus:
All of the ribbon information is stored in the “USysRibbons” table in xml format.
Here is an example of the xml:
This can be broken down into 3 main segments (at least for this example):
The Tabs
The Buttons
The Groups
The buttons will load the forms in the “tag” property, and the label (caption) of the button will
be in the “label” property.
Then you can load the ribbon when the database loads by doing this:
Also, be sure to include a module called “basRibbons” which contains the following code:
Option Compare Database Option Explicit 'reference to the MS Office 16.0 Office Library - ejl 9/19/18 Public globalRibbon As IRibbonUI 'Get a global reference to the ribbon object when the ribbon loads Public Sub OnRibbonLoad(ByVal Ribbon As IRibbonUI) Set globalRibbon = Ribbon End Sub 'Open the form that is specified in the ribbon control's tag property Public Sub ribOpenForm(control As IRibbonControl) DoCmd.OpenForm (control.Tag) End Sub 'Tell a ribbon control whether it should be enabled Public Sub ControlEnabled(control As IRibbonControl, ByRef enabled) Select Case control.ID Case "Employees" If CurrentProject.AllForms("frmEmployees").IsLoaded Then enabled = False Else enabled = True End If Case "Reports" If CurrentProject.AllForms("frmReportMenu").IsLoaded Then enabled = False Else enabled = True End If Case "Calendar" If CurrentProject.AllForms("frmCalendar").IsLoaded Then enabled = False Else enabled = True End If End Select End Sub
Hope this helps so far. I will probably be modifying this over time.
Let me know if you have any questions.
Learn Access VBA: Understand Tables, Queries, Forms, and Reports
Learn Access VBA: From Zero to Database Hero If you’ve ever opened Microsoft Access and wondered how all the pieces fit together — tables, queries, forms, and reports — this tutorial is made for you. In just a few minutes, you’ll understand how Access works behind the scenes and see how VBA (Visual Basic for […]
How to Fix Run Time Error 1004 in Excel
If you work with Microsoft Excel frequently, chances ar ling for a solution. Fortunately, this error is well-documented, and there are several ways to resolve it. In this article, we’ll explore the causes of run time error 1004, practical steps to fix it, and preventive measures to reduce the chances of it happening again. What […]
Error 91: Object Variable or With Block Variable Not Set — Causes and Solutions
If you work with VBA (Visual Basic for Applications) in Excel, Access, Word, or other Microsoft Office programs, you’ve probably come across the dreaded Error 91 at least once: Run-time error ‘91’: Object variable or With block variable not set This error can be frustrating, especially if your code seems perfectly fine at first glance. […]
How To Escape Apostrophe In SQL Update Query
If you are looping a table with thousands of records, you’ll probably run into at least one that has an apostrophe in the field name. Like “Mike’s” or “M’cormick”, or something else. Anyway, here is one way to escape the string when you are doing your update query. Option Compare Database Sub YDriveLoop() ‘4/23/24 erik@loeblcomservices.com […]
Support these sponsors: