Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
pkelly
Specialist
Specialist

List Box - Set to "Always One Selected" via code

Issues...

I have a report which shows QlikView Report Usage.

On tab 1, I want to show a chart showing the number of reports opened by users by day.

On tab 2, I want to show specific detail about a filtered report, update schedule etc...

I have all of this in place...

The issue that I have is that on tab 2, my filter needs to be set to "Always show one value" but having this disrupts tab 1 because this then only shows data for the filtered report when I need it to show for all...

What I would like to to is programatically play with the filter on tab 2...

When the sheet is activated, set the filter field value (qvw_Code) to "02A" then turn set the list box value to "Always One Selected Value" = true.

When the sheet is deactivated, set the list box value "Always One Selected Value" = false then clear the filters.

Can someone please give some guidance on the macro I need for setting the list box "Always One Selected Value"?

I have had a look at the APIguide with no joy....

Thanks

Paul

1 Solution

Accepted Solutions
Not applicable

Hi Paul,

here what you are looking for:

sub SetOneAndOnlyOne

set obj = ActiveDocument.GetSheetObject("LB01")

set boxfield=obj.GetField

set fprop = boxfield.GetProperties

if boxfield.GetFieldFlags.OneAndOnlyOne then

fprop.OneAndOnlyOne = false

else

fprop.OneAndOnlyOne = true

end if

boxfield.SetProperties fprop

end sub

every time you call the macro the filed wil be set or unset. Be carefull to have something that select one value before call the macro for set the OneAndonlyOne

Andrea

View solution in original post

5 Replies
kji
Employee
Employee

The property you are looking for is on the Field (not listbox) and is called OneAndOnlyOne.

Not applicable

Hi Paul,

here what you are looking for:

sub SetOneAndOnlyOne

set obj = ActiveDocument.GetSheetObject("LB01")

set boxfield=obj.GetField

set fprop = boxfield.GetProperties

if boxfield.GetFieldFlags.OneAndOnlyOne then

fprop.OneAndOnlyOne = false

else

fprop.OneAndOnlyOne = true

end if

boxfield.SetProperties fprop

end sub

every time you call the macro the filed wil be set or unset. Be carefull to have something that select one value before call the macro for set the OneAndonlyOne

Andrea

pkelly
Specialist
Specialist
Author

Thanks Andrea this has done the trick for me....

Regards

Paul

IAMDV
Luminary Alumni
Luminary Alumni

I just needed the same solution. Thanks to both for asking & answering.

Cheers - DV

Anonymous
Not applicable

Thanks for the code snippet.

I removed the If condition and I am using it with the OnOpen Trigger.