I have got this one working by using two buttons. But wanted to know the best possible approach to do this. can we achieve this using one button? Below is the scenario:
I have two reports. With the help of a button, I want to hide one report and activate another report. For example, If report 'A' is open, then on pressing the button, report 'A' should go and report 'B' should open. Similarly, If I press the button again, report 'A' should open and 'B' should hide.
Not quite sure what you're referring to here with "Report" (QVW document, Sheet or Actual report inside a QV doc?) but it should be fine. You can attach several actions to one button so that it goes through the steps you want.
It depends very much on how you hide/show the charts, (I understand that you mean chart -pivot or straight table- for report). But here's one approach, using one variable vShowChart in the conditional (chart properties, Layout, Show) to keep charts hidden and show one or the other. The text of the button is changed as well:
Sub ShowHideChart set vChart = ActiveDocument.Variables("vShowChart") set vBtnText = ActiveDocument.Variables("vButtonText") vChartS = vChart.GetContent.String if vChartS = "A" then vBtnText.SetContent "Show A Chart", true vChart.SetContent "B", true else vBtnText.SetContent "Show B Chart", true vChart.SetContent "A", true end ifEnd Sub