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.
Your suggestion are very much welcome. Thank you!
Solved! Go to Solution.
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
Hope that helps.
Thank you guys....!!
@Johannes: by report I meant the "Objects" and basically I am reffering to chart objects. So can you please help me in achieving this.
@Miguel: Thanks much bud. But I wanted to achieve this using Actions/Triggers only. I dont want to write any MAcros for this. Is it possible?
Many thx for your responses.
Yeah, in that case you might want to go with Nathan's solution using variables and Show Conditions for the objects that you want to hide/show.
Of course, just take the set variable action instead of the run macro in the External type of action in the button. The thing is that it's a conditional behaviour (show B and hide A).
The variable vButtonText shows the caption of the button. In the button, create a new action, External, Set Variable, and select vButtonText variable and set the following as Value.
=If(vButtonText = 'Show B Chart', 'Show A Chart', 'Show B Chart')
Add a new action, External, Set Variable, but use now vShowChart as variable and the following as value:
=If(vShowChart = 'A', 'B', 'A')
"A" and "B" are the values used in the Layout tab of the chart properties to show each of the charts.
Hope that helps.