Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
pkelly
Specialist
Specialist

Store list box selection in a variable

I have a list box and I would like to store the selected value(s) is a variable.

I think I have worked out how to get the value from the list box - "ProdFamily" is my list box field.

set prodfamilyselection=ActiveDocument.Fields("ProdFamily").GetSelectedValues

How do I store this in a variable?



1 Solution

Accepted Solutions
Not applicable

Hi,

here you are

sub StoreValues

set v = ActiveDocument.Variables("sel")
set doc = ActiveDocument
set mySelections = doc.fields("SW_Temp").GetSelectedValues
sel = chr(39) & mySelections.Item(0).text & chr(39)
for i = 1 to mySelections.Count - 1
sel = sel & chr(44) & chr(39) & mySelections.Item(i).text &chr(39)
next
v.SetContent sel,true

end sub

A QV example follows in a few minutes.

Rainer

View solution in original post

8 Replies
Not applicable

Hi,

here you are

sub StoreValues

set v = ActiveDocument.Variables("sel")
set doc = ActiveDocument
set mySelections = doc.fields("SW_Temp").GetSelectedValues
sel = chr(39) & mySelections.Item(0).text & chr(39)
for i = 1 to mySelections.Count - 1
sel = sel & chr(44) & chr(39) & mySelections.Item(i).text &chr(39)
next
v.SetContent sel,true

end sub

A QV example follows in a few minutes.

Rainer

Not applicable

Hi,

here are the application.

It´s not 100% perfect.

Rainer

pkelly
Specialist
Specialist
Author

Thanks Rainer - this is excellent and is exactly what I am looking for...

One quick question - in your example, how do you get the "sel" variable to update automatically when a list box selection is made?

Not applicable

Please remove the second macro.

Than the application runs without problems.

Rainer

Not applicable

Document Properties => Macros

See the screenshot.

Rainer

pkelly
Specialist
Specialist
Author

Thanks Rainer ... Your solution is exactly what I am looking for...

Not applicable

Thanks Rainer.... its really good one ...

Once again Thanks

Not applicable

I am using latest personal edition . I dont see macros Tab in Document properties. Could you help? Again my macros also dont recognize ActiveDocument Object