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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with Selected Values code

I have a requirement to load a table of filter values into a listbox from a spreadsheet these are in a seperate table with no common fields so isnt linked this is deliberate. These are all selected and loaded into an array with the code below (sf). I then want to set the Array contents as the current filter for another Listbox where %Key is linked to other objects. this should then filter all objects to the selected %key value. but the code isnt working !

The line thats Failing is below : is SelectValues supported in version 8.5 Or can someone point me towards my coding error ?

doc.Fields("%key").SelectValues sf







set doc = ActiveDocument
set myselections = doc.fields("TerritoryID").GetSelectedValues

set sf = doc.fields("%key").GetNoValues
for i = 0 to myselections.count -1
'msgbox (myselections.Item(i).text)
sf.Add
sf(i).Text = myselections.Item(i).text
sf(i).isNumeric = true
msgbox (sf(i).Text)

next

'doc.Fields("%key").select sf(0).Text 'this works but its only a single value
doc.Fields("%key").SelectValues sf 'This is the line that isnt working
end Sub







4 Replies
Not applicable
Author

here is a simpler code example but it is still not working ...

sub setFields
set doc = ActiveDocument
set fld = doc.fields("%key")
set x = fld.GetNoValues
x.Add
x.add
x.add
x(0).text = 1
x(1).Text = 2
x(2).Text = 3
ActiveDocument.fields("%key").SelectValues x
end sub

Not applicable
Author

Did you ever get an answer to this? I am running into the same problem. If the text is numeric, its fine. But as soon as its numeric, nothing that I put in the SelectValues sticks. I get no errors, it seems to be happy. I can see the values in the "x" array, but it never gets put into the field selection.

Not applicable
Author

I did get it working, but i believe its a workaround to a bug in the product.

when you populate the array value you have to set both properties for x.text and x.value

I dont have the qvw handy this evening but i can check it if the above solution doesnt work

ColinR

Not applicable
Author

Thanks for the information. At least I know its not something I'm doing wrong.

I couldn't get x.value to work - but I did find a work-around using ToggleSelect. I'm all set for now.

Sally