Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to clear the Always One selected value

Dear All,

  My problem is i have given the "Always One Selected value" in List Box Propeties.When i will go to the next sheet i need to clear all the selections whatever i have made in the sheet.

  I have given the trigger Clear All in On Activate sheet,except that List Box all selection are made clear.

  is there any possibility to do it.

Regards,

Santhosh

21 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Santhosh

Clear All does not work if you have always one selected enabled. The only way to clear all is to first remove the Always one selected property using a macro. I don't have a script for this but I have seen it on this forum before.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
its_anandrjs

Hi Santosh,

If you use differently all is ok in place of  "Always One Selected value" in List Box Propeties just remove this setting and try to put a Button to select always on value there like add a propertey on button "Select in Field" -> Then select Field -> and select Search String just click a button once it will automatically select one value in your list box. And when you go to next sheet use trigger or clear all fuctionallity.

See the attached sample file.

HTH

Rgds

Anand

Not applicable
Author

Hi Anand,

   But my Constraint is i don't want to allow to select morethan one value in Field.

Thanks & Regards

Santhosh Kumar

swuehl
MVP
MVP

Hi,

I think you could use following to achieve what I think you want:

Go to document properties --> triggers. In field event triggers, select your field you want to limit selection for.

Add an OnSelect action, action type is Select - Select in field.

Then enter your field name in the appropriate field entry box:

YOURFIELD

(just the name, no equal sign etc.).

as search expression use

=subfield(GetFieldSelections(YOURFIELD),',')

This should limit the selection to up to one value, but still allowing to clear the list box.

(tested on QlikView V10 SR3)

Regards,

Stefan

Not applicable
Author

Hi Stefen,

   Can i have any example application on this.it would be help full for me.

Thanks & Regards

Santhosh Kumar G

swuehl
MVP
MVP

Hi,

see attached.

Please note that clearing the field will lead to all values are in possible selection state, which is probably not what your requirement says.

Maybe you could work around this by applying a calculation condition to your objects, like =GetSelectedCount(YOURFIELD)>0

See also attached.

Hope this helps,

Stefan

IAMDV
Luminary Alumni
Luminary Alumni

Hi Santosh,

I have written the VB script for this functionality. I had exactly similar problem of restricting user to one selection yet making sure it works even you toggle to different sheets. I have this script in my work laptop and I can share it tomorrow morning. BTW - It is 10:58pm on Sunday night. I hope its okay with you.

Cheers - DV

swuehl
MVP
MVP

Hi Santhosh Kumar G,

seems I missed your request to clear all on changing to another sheet. But as you said, you could do this with another trigger and action on OnActivateSheet.

I still think your requirement to clear all on changing to another sheet and having a always one selected state is somewhat contrary. What do you do if someone changes back to the sheet with the alway one selected value field?

Regards,

Stefan

edit: Just in case you want to restore your orginal - but then cleared - selection in your field when returning to that sheet, I think you could do this with just two more actions triggered by OnActivateSheet and OnLeaveSheet, where you set / read back the selection to / from a variable.

See attached V2 of the sample.

IAMDV
Luminary Alumni
Luminary Alumni

Hi Santosh,

Sorry for not getting back yesterday. I have quickly mocked an example from Swuehl's QV file. I have used two Sub Procedures... one to enable the AlwaysSelectedOne and another to disable. I have called these two procedures on Sheet Properties Triggers, I have used the AlwaysOneSelected Procedure on Sheet Activate and before that event I have added one more event which selects a default value. In our case, I have used India as the default but you may set anything or best thing is to capture the last selection of the user of the field in the variable and use the variable to recall the last selection in the trigger. And I have used RemoveAlwaysOneSelected procedure OnDeactiveSheet event.

Here are the VB Script Procedures :

Sub AlwaysOneSelected

    set obj = ActiveDocument.GetSheetObject("LB02")

    set boxfield=obj.GetField

    set fprop = boxfield.GetProperties

                fprop.OneAndOnlyOne = True

            boxfield.SetProperties fprop

End Sub

Sub RemoveAlwaysOneSelected

    set obj = ActiveDocument.GetSheetObject("LB02")

    set boxfield=obj.GetField

    set fprop = boxfield.GetProperties

            fprop.OneAndOnlyOne = False

            boxfield.SetProperties fprop

            ActiveDocument.ClearAll True

End Sub

I hope this makes sense and hope it helps to meet your requirement.

Cheers - DV