I created two sheets namely sheet1 and sheet2. I don't want sheet1 selections to be affected on sheet2 . Here the list box in sheet1 is checked with 'Always one selected value'.
If I had selected some filters on sheet1 and when I switch to second sheet it should get cleared . At the same time when i come back to sheet1 it should have the same selections .
For this , I used the bookmarks trigger on sheet properties. It leads me to the issue that whenever I switch from sheet 2 to Sheet1 , It shows me the same selections which created bookmark for the first time.
So, however I managed to write a macro by surfing so many blogs eventhough I am new to macro's section in qlikview.
Sub AlwaysOneSelected Set QvObj=Activedocument.GetSheetObject("LB28") Set MyField=QvObj.GetField Set FieldProp=MyField.GetProperties FieldProp.OneAndOnlyOne=True MyField.SetProperties FieldProp End Sub
Sub RemoveOnlyOneSelected Set QvObj=Activedocument.GetSheetObject("LB28") Set MyField=QvObj.GetField Set FieldProp=MyField.GetProperties FieldProp.OneAndOnlyOne=False MyField.SetProperties FieldProp ActiveDocument.ClearAll True End Sub
After writing macro I used the external and Select in field triggers on sheets but it again leads me to the same issue.
Can someone please help me in correcting this macro ? or any new solution.
A great way of starting a clean selection each time you activate a sheet is using Qlikview's built-in 'clear' OnActiveSheet feature. This is not a direct answer to your question, but i note here since its a useful feature. Perhaps the macros are not necessarily needed.
Setting -> Document Properties -> select Sheets tab -> click on the SheetID/Title you want to have cleared on activating -> click on Properties (note -- if you have not selected the sheet you want to apply this to, Properties will be greyed out) -> Click Add Action or Edit Action(s) under 'OnActiveSheet' -> Click Add -> select Action Type 'Selection' and Action 'Clear All'.
Each time you then activate the given Sheet, the 'Current Selections' will be cleared.