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.
How to Delete Blank Rows in Excel Using VBA (Step-by-Step Guide)
How to Delete Blank Rows in Excel Using VBA (Step-by-Step Guide) When you work with large datasets in Excel, it’s common to end up with thousands of blank rows scattered throughout your worksheet. Maybe your data came from a mainframe export, a CSV download, or a legacy system that doesn’t format properly. Deleting all those […]
How to Copy Data from One Worksheet to Another Using VBA in Excel
Learn how to copy data between worksheets in Excel using VBA step-by-step! This quick tutorial shows how to automate data movement, save time, and boost productivity. Watch: How to Copy Data from One Worksheet to Another Using VBA Why Automate Copying Data Between Worksheets? Copying and pasting data manually can take up valuable time and […]
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 […]
Support these sponsors:






