Forum Discussion

eddypi123's avatar
eddypi123
Copper Contributor
Dec 05, 2024
Solved

How to restore selected ribbon tab after report with a custom ribbon is closed?

We have a database which has two ribbons.

A Switchboard ribbon with multiple tabs and a hidden PrintPreview ribbon used through report “Ribbon Name” property.

The PrintPreview ribbon has startFromScratch="true".

The tabs of Switchboard ribbon have multiple buttons use for opening a corresponding report.

The problem is that each time a user opens and closes a report the Switchboard ribbon jumps back to first tab.

Example:

Switchboard has tab1, tab2.
The tab1 has button1 and button2 to open report1 and report2 correspondently.
The tab2 has button3 and button4 to open report3 and report4 correspondently

All 4 reports have “Ribbon Name” property set to PrintPreview ribbon.

User clicks report3 from tab2. The report3 is opens, Switchboard ribbon is hidden and PrintPreview ribbon is visible.
User close report3. The Switchboard ribbon became visible and tab1 is an active tab.
Now user need to click on tab2 again if he/she want to open report4 or even report3 again.

If we extrapolate this situation for 17 tabs on Switchboard ribbon with each tab having ~20 reports we can see user frustration with moving focus back to first tab.

Is where a way to remember which tab in Switchboard ribbon was active before opening PrintPreview ribbon and make it active after report is closed?

Note:  the only possible solution I found  was with use of Ribbon Accessibility here www.wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
It is a quite complicated and does not works under Access 365 too.

Any help would be appreciated! Thank you!

  • after you the report is closed and after showing the Switchboard ribbon, you Activate which tab the closing report belongs, eg:

     

        gobjRibbon.ActivateTab "tab2"

  • eddypi123's avatar
    eddypi123
    Copper Contributor

    Hi Arnel_gp,

    Thank you foryour help.

    I tried to avoid modifying 300+ reports and extra coding, but looks like Microsoft, as usual, did half cooked job this its beloved ribbon and left no chose for VBA and Office developers as to waste time on work arounds.

  • eddypi123's avatar
    eddypi123
    Copper Contributor

    I am aware of ActivateTab method. 
    However, for gobjRibbon.ActivateTab "tab2" to work, I need to know that “tab2” was an active tab from which report button has been pressed.
    I am looking for a simple solution to find our from which Tab user open the report. 
    The only way to achieve that at the moment is to hard code tab's names into onAction event for each report buttons. I try to avoid it, as our database solution contains 300+ reports.

    • arnel_gp's avatar
      arnel_gp
      Steel Contributor

      that is very easy, manually save the tab name to a Tempvar or Global variable:

      Sub OnActionButton(control As IRibbonControl)
          Select Case control.ID
          Case "Report01"
              'Report01 is on Tab1
              Tempvars("tvarTab") = "Tab1"
              'open the report01 below
          Case "Report02"
             'Report02 is on Tab2
              Tempvars("tvarTab") = "Tab2"
             'open report02 below
          Case Else
              Msgbox "Button """ & control.ID & """ clicked."
          End Select
      
      End Sub

      now when you the report closed just:

       

       gobjRibbon.ActivateTab Tempvars!tvarTab.Value

  • arnel_gp's avatar
    arnel_gp
    Steel Contributor

    after you the report is closed and after showing the Switchboard ribbon, you Activate which tab the closing report belongs, eg:

     

        gobjRibbon.ActivateTab "tab2"

Resources