title: access 2010 custom ribbon
body: <p>I have a custom ribbon that calls vba commands. When it does, I get the error message</p>
  
  <pre><code>Microsoft Access cannot run the macro or callback function [FUNCTION OR SUB]
  </code></pre>
  
  <p>where <code>[FUNCTION OR SUB]</code> is the Function or Sub name I am calling.</p>
  
  <p>An example of the code that generates the above message is:</p>
  
  <pre><code>Public Function OnButtonPress2(ctl As IRibbonControl)
  
      MsgBox "OnButtonPress2"
  
  End Function
  </code></pre>
  
  <p>Where <code>OnButtonPress2</code> is called in the ribbon's XML file for a button as</p>
  
  <p><code>onAction="OnButtonPress2</code></p>
  
  <p>The above works for a macro, so it's likely not to be the ribbon's xml</p>
  
  <p>======== VERSION 2
  I've created a new simple test db with the XML and module shown below:</p>
  
  <p>The results of each are:</p>
  
  <p>Macro1 - works fine (it has a popup message)</p>
  
  <p>CommandOnAction2 - msgbox "There was an error compiling this function"</p>
  
  <p>OnButtonPress2 - msgbox  "Microsoft Access cannot run the macro or callback function 'OnButtonPress2 '</p>
  
  <p>on the line "Public gobjRibn As IRibbonUI", IRibbonUI does not autocomplete leading me to believe there is a reference that needs to be added</p>
  
  <p><strong>XML (Ribbon name is NewRibbon and is set to open on startup)</strong></p>
  
  <pre><code>&lt;customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"&gt;
  &lt;ribbon startFromScratch="false"&gt;
  &lt;tabs&gt;
  &lt;tab id="tab1" label="Your Custom Tab"&gt;
  
  &lt;group id="group1" label="Your Custom Group"&gt;
  &lt;button id="SampleButton" label="Macro1" onAction="Macro1" /&gt;
  &lt;button id="SampleButton2" label="CommandOnAction2" onAction="=CommandOnAction2()"  /&gt;
  &lt;button id="SampleButton3" label="OnButtonPress2" onAction="OnButtonPress2"  /&gt;
  &lt;/group&gt;
  &lt;/tab&gt;
  &lt;/tabs&gt;
  &lt;/ribbon&gt;
  &lt;/customUI&gt;
  </code></pre>
  
  <p><strong>module (name is modRibbon)</strong></p>
  
  <pre><code>Option Compare Database
  
  Public gobjRibn As IRibbonUI
  
  Public Function CommandOnAction2(ByVal ctl As IRibbonControl)
      MsgBox "Function CommandOnAction2"
  End Function
  
  Public Sub OnButtonPress2(ByVal ctl As IRibbonControl)
      MsgBox " Sub OnButtonPress2"
  End Sub
  </code></pre>