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: 
rcorcoran
Creator
Creator

Clearing always one on list box on leaving sheet

Hi I am trying to remove the always one selected on a list box when I leave a sheet and re-activate when I go back to the sheet.

I have the following sub and have the first one in the trigger for on opening sheet and the second one for when you leave the sheet.

It is getting rid of the always one selected when I leave the sheet but it is not re-applying when I go back to it.

Any help would be great

Thanks

Sub Alwaysoneselected

Set QvObj = ActiveDocument.GetSheetObject ("LB202")

Set MyField = QVObj.GetField

Set FieldProp = MyField.GetProperties

FieldProp.OneandOnlyOne = True

MyField.SetProperties FieldProp

End Sub

Sub RemoveAlwaysoneselected

Set QvObj = ActiveDocument.GetSheetObject ("LB202")

Set MyField = QVObj.GetField

Set FieldProp = MyField.GetProperties

FieldProp.OneandOnlyOne = False

MyField.SetProperties FieldProp

ActiveDocument.ClearAll True

End Sub

5 Replies
m_woolf
Master II
Master II

Your need a MyField.Select statement before the OneandOnlyOne = False line.

tresesco
MVP
MVP

Since there is no value selected before you call macro 'Alwaysoneselected', the 'OneandOnlyOne' won't work. So try to use a trigger to select a value from the list first then call the macro to enable the property. Check the sample attached.

tresesco
MVP
MVP

Or, yes (as m w says above), simply add one more line to replace the additional trigger, like:

Set QvObj = ActiveDocument.GetSheetObject ("LB202")

Set MyField = QVObj.GetField

Set FieldProp = MyField.GetProperties

ActiveDocument.Fields("YourField").Select "AValue"

FieldProp.OneandOnlyOne = True

MyField.SetProperties FieldProp

avinashelite

I could suggest using a triggers .

Go to sheet Properties > Triggers > Onactivatesheet

                                                  > Onleavesheet

is it the requirement to go with Always one selected value?? because using sheet trigger can easily select and deselect a field value ,

jagan
Luminary Alumni
Luminary Alumni

Hi,

You can use sample macro from this link for this purpose in the  Onactivatesheet and Onleavesheet triggers.

Useful Qlikview Macros