Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Not applicable

Macro

Hi Everyone,

I need a help on macro.

I have two tabs in one report. I have selection boxes on both tabs. When I move from first tab to second tab, I need to clear the selection boxes.I did that using the below macro,

sub Clear
ActiveDocument.Fields("F1").clear
end sub

Now, when I move back to first tab, I need the same selection which I selected previously (prior to moving to second tab). could someone help me with the macro.

Ex: I clear the selection made on "F1", when I move to 2nd tab. I need the selection made on "F1" to be present, when moved to 1st tab.

Please see the attachment

Pascal

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Macro

Hello Pascal,

Using a public variable should do the trick:

Public Selection

sub AwayFromTab1
set Selection = ActiveDocument.Fields("F1").GetSelectedValues
ActiveDocument.Fields("F1").clear
end sub


sub BackToTab1
set f1 = ActiveDocument.Fields("F1")
f1.SelectValues Selection
end sub


I hope this helped you out.

Mark

5 Replies
Not applicable

Macro

Hello Pascal,

Using a public variable should do the trick:

Public Selection

sub AwayFromTab1
set Selection = ActiveDocument.Fields("F1").GetSelectedValues
ActiveDocument.Fields("F1").clear
end sub


sub BackToTab1
set f1 = ActiveDocument.Fields("F1")
f1.SelectValues Selection
end sub


I hope this helped you out.

Mark

Not applicable

Macro

Public selarr()

Public fldarr()

Public valcount

sub LeaveTab

valcount=ActiveDocument.Fields("$Field").GetCardinal

set vals=ActiveDocument.Fields("$Field").GetPossibleValues

Redim selarr(valcount)

Redim fldarr(valcount)

for i=0 to valcount-1

fldarr(i)=vals.Item(i).text

set selarr(i)=ActiveDocument.GetField(vals.Item(i).text).GetSelectedValues

next

ActiveDocument.clearAll false

end sub

sub ReturnToTab

for i=0 to valcount-1

ActiveDocument.GetField(fldarr(i)).SelectValues selarr(i)

next

end sub



Not applicable

Macro

Thanks Jay and Janseen. It worked as I expected.

Not applicable

Macro

You're welcome, but where is Jay's solution?

Not applicable

Macro

It's reposted now.

Community Browser