Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
megabyte23
Contributor III
Contributor III

Change active tab in container programmatically

Hello,

I have a container with a set of tabs. In certain instances, clicking on a filter would only be relevant to one tab, so if the user clicks it, I would like to automatically display that tab.

For example, say these are the tabs:

    [Dog Owners]

    [Labradors]

    [Beagles]

    [Poodles]

    [Dogs By County]

Within the result sets will be "Labradors", "Beagles" and "Poodles". If someone selects "Poodles", I would like it to move to the "Poodles" tab. If I could run a macro when the filter selection changes, I could probably code it in there, but I'm not seeing a way to do it.

I appreciate any insight.

1 Solution

Accepted Solutions
marcus_sommer

I think you could adapt the following to your requirements: Re: Select Tab in the Container using Macro.

An alternatively would be to emulate the container with a textbox as frame and multiple buttons/textboxes as tabs. Now each click on them could change variable-values and/or the selection of any fieldvalues could be used to control the visibility of your charts.

- Marcus

View solution in original post

4 Replies
marcus_sommer

I think you could adapt the following to your requirements: Re: Select Tab in the Container using Macro.

An alternatively would be to emulate the container with a textbox as frame and multiple buttons/textboxes as tabs. Now each click on them could change variable-values and/or the selection of any fieldvalues could be used to control the visibility of your charts.

- Marcus

megabyte23
Contributor III
Contributor III
Author

Thanks Marcus,

Update: attached .QVW sample in case anyone would like to use this functionality.

I was able to do this in tandem with other research. I would like to attach my .QVW in case someone else needs it, but I don't see where to do that.

Essentially there are 5 parts:

1. Container as outlined in my question

2. Listbox with dog breeds

3. Set up global variable vBreedSelected

4. Document Properties -> Triggers -> OnAnySelect -> Run Macro

4. Here's the macro:

sub ContTabSelect

dim strValueToDisplay

set SelectedVal1 = ActiveDocument.fields("Breed").GetSelectedValues
If SelectedVal1.count > 0 Then 'set tab if not blank
  strValueToDisplay =  SelectedVal1.item(0).text

  'msgbox("The value of ""vBreedSelected"" is: " & strValueToDisplay)
  ActiveDocument.Variables("vBreedSelected").SetContent strValueToDisplay, true
End If
 
'set TabNumb = 0
Select Case strValueToDisplay
  Case "Labradors"
   TabNumb = 1
  Case "Beagles"
   TabNumb = 2
  Case "Poodles"
   TabNumb = 3
  Case Else
   TabNumb = 0
End Select


set MV_ContainerObj = ActiveDocument.GetSheetObject("CT01")
Set MV_ContProp = MV_ContainerObj.GetProperties
MV_ActiveIndex2 = MV_ContProp.SingleObjectActiveIndex
MV_ActiveIndex2 = TabNumb
MV_ContProp.SingleObjectActiveIndex = MV_ActiveIndex2
MV_ContainerObj.SetProperties MV_ContProp


End Sub

marcus_sommer

To upload a file see: Uploading a Sample.

- Marcus

megabyte23
Contributor III
Contributor III
Author

Great- I edited the post and was able to attach it. Thanks again @Marcus_Sommer.