Adding Macros to the ribbon in MS Access using USysRibbons

I'm new to using xml, but not new to Access or VBA. I need to create a deployable ribbon that can be customized upon load based on the users role. I am creating this ribbon using a USysRibbons table to hold the XML code. I can add built-in controls no problem. Where I am stuck is adding controls that call saved macros or procedures. Below is code I'm testing with, but line 6 doesn't work. Any help is appreciated!

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon startFromScratch="true">
    <tabs>
      <tab id="dbChecklists" label="zChecklists" visible="true">
        <group id="dbRCL_Forms" label="Forms">
          <control idMso="Macro: macRCL_Add" label="Add" enabled="true"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Open in new window

Level7SenseiAsked:
Who is Participating?
 
Level7SenseiAuthor Commented:
OK I finally got it to work. Apparently you can't use the enabled switch for a button?

          <button id="RCL_Add" label = "AddMe" onAction="macRCL_Add"  />

Open in new window

0
 
mbizupCommented:
Here's an example from one of my databases, of a ribbon button that adds a new client record.  You can call a procedure using the onAction.  The XML:

                    <button id="btnNewClient"
                              imageMso="QueryAppend"
                              label="Add new client"
                              size="large"
                              onAction="btnNewClient_Click"/>

Open in new window


The VBA:

Public Sub btnNewClient_Click(ctl As IRibbonControl)
    DoCmd.GoToRecord acDataForm, "frmClients", acNewRec

End Sub

Open in new window

0
 
mbizupCommented:
There are also third party tools available, such as Ribbon Creator, which make very short work of this.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Level7SenseiAuthor Commented:
Still no luck. I changed line 6 to the following:
          <button id="RCL_Add" label = "Add" onaction="btnAdd_RCL" enabled="true"/>

Open in new window


And I added a public procedure as you showed:
Public Sub btnAdd_RCL()
    DoCmd.OpenForm "frmRCL_Add"
End Sub

Open in new window


The XML part isn't being accepted. What am I missing? Thanks.
0
 
mbizupCommented:
Interesting!  I actually haven't tried the enabled property on a ribbon command button.  I'll check it out tomorrow... Perhaps you need a similar property such as Locked (?)
0
 
Level7SenseiAuthor Commented:
Primary failure was using the illegal switch of 'enabled="true"'.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.