Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
Not applicable
Author

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

View solution in original post

5 Replies
Not applicable
Author

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
Author

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
Author

Thanks Jay and Janseen. It worked as I expected.

Not applicable
Author

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

Not applicable
Author

It's reposted now.