title: update ribbon label and image based on values in a table
body: <p>I have a custom ribbon, I'd like to make one of the buttons dynamic based on values in a table
  so, when the form is closed, I'd like for the ribbon button and label to change based on changes made in the form (if there were any)</p>
  <p>Here's my VBA code just for that button.
  And I created 2 separate buttons with different images and labels in the USysRibbonImages table. I have mine setup a tad different, that table also stores button names, macro names and labels, besides the images. I did it that way since each image record can only be tied to one button anyway, so, figured I might as well make my images into buttons in the same table. And this process is automated somewhat. I'm explaining in case someone wonders why the code is a little different from what you usually see for ribbons.</p>
  <p>But it works fine for static ribbons, it's once I want to make them a little dynamic is where I have issues</p>
  <pre><code>Public Sub fnGetRibbonImages(control As IRibbonControl, ByRef image)
  
  Dim attach As Attachment
  DoCmd.OpenForm &quot;fZRibbonImages&quot;, acNormal, , , , acHidden
      
      If control.ID = &quot;btnServicesShippingWeightBucketsCollections&quot; Or control.ID = &quot;btnServicesShippingWeightBucketsCollectionsRed&quot; Then
          'regular
           If dCount(&quot;MissingServicesShippingWeightBucketsID&quot;, &quot;MissingServicesShippingWeightBuckets&quot;) &gt; 0 Then
              Forms(&quot;fZRibbonImages&quot;).Filter = &quot;([USysRibbonImages].[ButtonName]='btnServicesShippingWeightBucketsCollections')&quot;
          Else
          'red
              Forms(&quot;fZRibbonImages&quot;).Filter = &quot;([USysRibbonImages].[ButtonName]='btnServicesShippingWeightBucketsCollectionsRed')&quot;
          End If
              Forms(&quot;fZRibbonImages&quot;).FilterOn = True
              Set attach = Forms(&quot;fZRibbonImages&quot;).Controls.Item(&quot;Images&quot;)
              Set image = attach.PictureDisp()
      End If
   
  DoCmd.Close acForm, &quot;fZRibbonImages&quot;, acSaveYes
  
  End Sub
  
  Public Sub GetRibbonLabel(ByVal control As Office.IRibbonControl, ByRef returnedVal)
  
      If control.ID = &quot;btnServicesShippingWeightBucketsCollections&quot; Or control.ID = &quot;btnServicesShippingWeightBucketsCollectionsRed&quot; Then
          If dCount(&quot;MissingServicesShippingWeightBucketsID&quot;, &quot;MissingServicesShippingWeightBuckets&quot;) &gt; 0 Then
              returnedVal = &quot;FIX!!!!!&quot;
          Else
              returnedVal = &quot;Buckets&quot;
          End If
      End If
    End Sub
  </code></pre>
  <p>And here's my ribbon xml (I removed a bunch of buttons, the code is the same for all)</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;customUI
      xmlns=&quot;http://schemas.microsoft.com/office/2006/01/customui&quot; onLoad=&quot;OnLoadRibbon&quot; loadImage=&quot;OnLoadImage&quot;&gt;
      &lt;ribbon startFromScratch=&quot;true&quot;&gt;
          &lt;tabs&gt;
              &lt;tab id=&quot;tabDefault&quot; label=&quot;App Options&quot;&gt;
                  &lt;group id=&quot;grpMappings&quot; label=&quot;Mappings&quot;&gt;
                      &lt;button id=&quot;btnZoneXWalk&quot; label=&quot;Zone Xwalk&quot; onAction=&quot;mZoneXWalk&quot; getImage=&quot;fnGetRibbonImages&quot; size=&quot;large&quot;/&gt;
                      &lt;button id=&quot;btnServicesShippingWeightBucketsCollections&quot; label=&quot;Shipping Weight Buckets&quot; onAction=&quot;mServicesShippingWeightBucketsCollections&quot; getImage=&quot;fnGetRibbonImages&quot; size=&quot;large&quot;/&gt;
                  &lt;/group&gt;
              &lt;/tab&gt;
          &lt;/tabs&gt;
      &lt;/ribbon&gt;
  &lt;/customUI&gt;
  </code></pre>
  <p>I tried putting this with the CLOSE button for the form</p>
  <pre><code>sbRefreshRibbon
  MyRibbon.Invalidate
  </code></pre>
  <p>And here's the code for the sbRefreshRibbon sub</p>
  <pre><code>Public Sub sbRefreshRibbon()
  On Error GoTo RestartApp
  MyRibbon.Invalidate
  On Error GoTo 0
  Exit Sub
  RestartApp:
    MsgBox &quot;Please restart Application for Ribbon changes to take effect&quot;, _
      vbCritical, &quot;Ribbon Refresh Failed&quot;
  End Sub
  </code></pre>
  <p>No luck, except after a few changes (don't remember exactly what I did, I've been at this for a while) I got an error that said to restart to reload the ribbon</p>