Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I've been looking for a way to do the following on a QVW that has, say, a list box of Products and a chart showing those Products Sales over some time period:
- have a button that says "Add Selected Product to LIst" (ie. an array)
- have a button that says "Select all Products from List" (ie, force the array of vales into a selection for a list box)
- now I'd like to be able to:
1. select a Product from the List Box
2. click the "Add to List" button (putting the selected value in an array)
3. clear all selections
4. select another Product from the List Box
5. click the "Add to List" button. (now my behind the scenes array has 2 products in it.)
6. click the "Select all Products from List". (this would now show my 2 chosen products on my chart as if I had just selected both of them from my List Box.)
What I'm trying to accomplish is a "running bucket of selections" that can be accumulated during a session where you are selecting and deselecting multiples items. The running list can at some point then be used to select all of the chosen values at once.
Thanks for any suggestions,
-Jeff
You could use a QlikView variable to store your list. No need for an array, a comma separated list will work fine (I believe you can use the VB function split in VBScript, but haven't verified that). You would probably also want a variable set to GetFieldSelections(Field) to be used by your macro. Then:
Sub Add2List
oldList = ActiveDocument.Variables("vProdList").GetContent.String
newItems = ActiveDocument.Variables("vGetFieldSelections").GetContent.String
ActiveDocument.Variables("vProdList").SetContent oldList & "," & newItems, true
End Sub
I haven't tested any of that, but the logic should handle what you are looking for.
EDIT: I forgot the hard part. Here is the sub to select your value list:
Sub Selector
valueList = ActiveDocument.Variables("vProdList").GetContent.String
valueAry = Split(valueList, ",")
ActiveDocument.Fields("Customer").Select valueAry(0)
For i = 1 to UBound(valueAry)
ActiveDocument.Fields("Customer").ToggleSelect valueAry(i)
Next
End Sub
You'll probably need some logic to make sure at least one value is selected (GetSelectedCount(FIELD)).
EDIT 2: GetFieldSelections uses a comma space. You can either change the SetContent in the first sub to ", " and the split to a ", " or do a trim on the valueAry array values. I'd probably do the latter and use:
ActiveDocument.Fields("Customer").Select Trim(valueAry(0))
...
ActiveDocument.Fields("Customer").ToggleSelect Trim(valueAry(i))