Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Run a Macro after The Clear Button is clicked

Hi,

In my qvw I have some selections that I realy need to maintain some consistences. However, when I click on the Clear Button, All selection

is gone (including the Locked ones).

Is there a way to run a macro after I clicked the Clear Button ? Or some other way to force running a macro after that ?

Thanks!!

4 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

You can trigger an Action (including a macro) off "OnAnySelect" event - it's defined in Document Properties, "Triggers". I'm not totally positive, but I think "OnAnySelect" should get triggered when all selections are cleared.

Within the macro, you can then validate what selections are made, and build your logic accordingly.

erichshiino
Partner - Master
Partner - Master

Oleg's approach will give you more possibilities. However, depending on you need you could set a clear state to return the selection to a previously determined setting when the user click on clear (instead of clearing everything).

Make your selections, go to the clear button and open a small combo box on the right.

Click set clear state.

After this, the clear button go back to this selection.

Rgds,

Not applicable
Author

The OnAny Select appears to apply when you make any selection, not only with the Clear Button.

I liked the Idea of the Clear State, but there's a problem: it doesn't save the values of the variables. Any idea how to solve that ?

Thanks !!!

erichshiino
Partner - Master
Partner - Master

Hi,

I was able to run a macro when all the selections were cleared.

First, I created a variable vClear = isnull(GetCurrentSelections())

It can be true or false.

After that, I include a OnChange trigger on this variable to call a macro (message)

with the following code:

sub message

set x = ActiveDocument.GetCurrentSelections

s = x.Selections

v = x.VarId

'msgbox ActiveDocument.ActiveSheet.GetCurrentSelections.count

if ubound(s)<0 then

msgbox ("You cleared all the selections")

end if

end sub

Instead of the msgbox you could have any code.

I couldn't find a way to dfferenciate a clear button from a one-by-one clear field.

I include my sample app here

Hope it helps,

Erich