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 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 […]
How To Make An Access Form Time Picker
Here is a relatively easy way to select times for your time entry text boxes. It’s a reusable form that allows you to pick a time from an Access form. There are probably different ways to do this but here is the way I would do it. On the form that has the time fields, […]
How To Parse A Flat File In Excel VBA
In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]
How to pick a file to load In VBA
Picking a file to load in your Microsoft App is a very important skill to know. In this blog post you will see how to do it. First you need to set a reference to the MS office object library From VBE editor –> select Tools > MS office object library (click check mark) Sub […]