How to Programatically Choose a Ribbon (Access 2007) (1 Viewer)

DJDave

New member
Local time
Yesterday, 23:45
Joined
Jan 21, 2014
Messages
6
Short and sweet version: Is there a way to programatically choose what RIBBON NAME is specified in the CURRENT DATABASE section of the ACCESS OPTIONS (Access 2007)? (See attached image)

So I've been hunting for this for a couple hours and turned up nothing so far. I've hit a thread here on AP (www,access-programmers,co,uk/forums/showthread.php?t=231823) that touches the topic but is not really "solved." In brief, it discusses how to MAKE RIBBONS AVAILABLE for use, but it does so using a kind of inverse logic; it renames the ribbons themselves while leaving the name in the box (in the Access Options) alone. I'm thinking that there has GOT to be a way to change the value that's in this box using VBA, but for the life of me I can't find it. Please see the attached image to get a better idea of what I mean...
 

Attachments

  • RibbonSet.jpg
    RibbonSet.jpg
    77.8 KB · Views: 142
Last edited:

MarkK

bit cruncher
Local time
Yesterday, 23:45
Joined
Mar 17, 2004
Messages
8,179
If you run this code you can see the various property name/values pairs for CurrentDb.
Code:
[SIZE="2"]Private Sub ShowProperties()
On Error GoTo handler
    Dim prp As DAO.Property
    
    For Each prp In CurrentDb.Properties
        Debug.Print prp.Name & ": ",
        Debug.Print prp.Value
    Next
    
    Exit Sub
handler:
    Debug.Print err.Description
    Resume Next
    
End Sub[/SIZE]
If you have it set, there is a CustomRibbonID property that is the name of the current database's ribbon. In quick testing, if you add or delete this property programmatically, it doesn't have any effect until you re-open the database.

A more common approach to set the ribbon of your choice is to set the RibbonName property of an open form. That displays that ribbon while that form is open.
 

DJDave

New member
Local time
Yesterday, 23:45
Joined
Jan 21, 2014
Messages
6
If you run this code you can see the various property name/values pairs for CurrentDb.
Code:
[SIZE="2"]Private Sub ShowProperties()
On Error GoTo handler
    Dim prp As DAO.Property
    
    For Each prp In CurrentDb.Properties
        Debug.Print prp.Name & ": ",
        Debug.Print prp.Value
    Next
    
    Exit Sub
handler:
    Debug.Print err.Description
    Resume Next
    
End Sub[/SIZE]
If you have it set, there is a CustomRibbonID property that is the name of the current database's ribbon. In quick testing, if you add or delete this property programmatically, it doesn't have any effect until you re-open the database.

A more common approach to set the ribbon of your choice is to set the RibbonName property of an open form. That displays that ribbon while that form is open.

Thanks MarkK!! :D This is exactly what I was looking for! Seems Microsoft doesn't have a habit of documenting these little things too well... as I've learned after several months of learning and developing in Access/VBA.

The set-then-restart convention doesn't bother me, it's actually key to what I'm trying to accomplish. Tested it and got it workin' -- thanks a BUNCH!!
 

MarkK

bit cruncher
Local time
Yesterday, 23:45
Joined
Mar 17, 2004
Messages
8,179
You're very welcome.

A thing to know about Access that may help it make more sense, is that it evolved from a few different software bundles. The database engine is Jet, or now ACE. Queries and Tables (QueryDefs and TableDefs) are DAO (Data Access Objects). The programming environment is provided by VBA, so those are the Standard and Class Modules.

So DBEngine, Tables, Queries, and Modules, some major programming chunks, aren't really native to Access. Access sort of welds them together, and provides the Form and Report objects. So Access is not a monolithic package designed from the ground up. It has distinct fault lines that make understanding the whole things someone quirky and nuanced.

Cheers,
 

vbaInet

AWF VIP
Local time
Today, 07:45
Joined
Jan 22, 2010
Messages
26,374
You're very welcome.

A thing to know about Access that may help it make more sense, is that it evolved from a few different software bundles.
Microsoft are experts at this - look at their other software :)
 

Users who are viewing this thread

Top Bottom