Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hopefully someone can help me with this one...
What I am trying to achieve...
I want to see if the user has selected a value from my family filter...
If they have, put the value in the variable "varQtyShow" otherwise set the value of this filter to "No"...
The issue...
If I only use the family filter the above works okay...
i.e. If no values selected varQtyShow = "No" / if values selected my variable shows these...
If I have selected a value from my family filter (varQtyShow therefore values shown) then select a value from one of my other filters (in the example I have provided I have also ABC) - varQtyShow resets to NO...need this to be the filtered values...
This is even though I have a family filter value selected...
Please excuse my ramblings on this - hopefully semeone gets the jist of what I am trying to do...
Try this?
sub ListBoxCheck
set v = ActiveDocument.Variables("varQtyShow")
set doc = ActiveDocument
set mySelections = doc.fields("%ProductFamilyKey").GetSelectedValues
varQtyShow = chr(39) & left(mySelections.Item(0).text,2) & chr(39)
for i = 1 to mySelections.Count - 1
varQtyShow = varQtyShow & chr(44) & chr(39) & left(mySelections.Item(i).text,2) &chr(39)
next
if doc.fields("%ProductFamilyKey").GetSelectedValues.Count = 0 Then
v.SetContent "No", true
Else
v.SetContent varQtyShow, true
End If
end sub
EDIT: You beat me to it! The API Guide is the best resource for anything related to macros in QlikView. It should be installed with the application, but you can grab it from: http://global.qlik.com/download/
The reset sub is being called when a selection is made on the ABC field. I removed the onChange macro from Family and it stopped happening. I don't know why the onChange of Family is being triggered when a selection is made on ABC.
Do you need that event to call the reset? In what situations are you needing to reset the variable, maybe there is another way?
EDIT: I just looked at the manual and onChange is called any time a selection is made on a field associated with the field. This is the behavior you are seeing. I don't think you want the reset to be called on that event.
Thanks...this explains what is happening...I thought the OnChange would just relate to the field I was on...
Suppose I am half way there...
I need the variable "varQtyShow" to be set to "No" when there are no values selected in the Family filter....
Earlier today @ work I tried doing this as an If, Else End If but hit an error on the get selected values when there was no value selected in the family filter..
Any help greatly appreciated....
Saw a response you made to a different post and I think I have now solved this...
Please see attached...
As an additional question...
What is the best resource for learnning commands such as "GetValueCount"?
Many Thanks
Try this?
sub ListBoxCheck
set v = ActiveDocument.Variables("varQtyShow")
set doc = ActiveDocument
set mySelections = doc.fields("%ProductFamilyKey").GetSelectedValues
varQtyShow = chr(39) & left(mySelections.Item(0).text,2) & chr(39)
for i = 1 to mySelections.Count - 1
varQtyShow = varQtyShow & chr(44) & chr(39) & left(mySelections.Item(i).text,2) &chr(39)
next
if doc.fields("%ProductFamilyKey").GetSelectedValues.Count = 0 Then
v.SetContent "No", true
Else
v.SetContent varQtyShow, true
End If
end sub
EDIT: You beat me to it! The API Guide is the best resource for anything related to macros in QlikView. It should be installed with the application, but you can grab it from: http://global.qlik.com/download/