Selecting previous value in listbox using button in Qlikview

The list box is the most basic sheet object. It contains a list of all possible values of a specific field. Each row in the list box can represent several records in the loaded table, all with identical values. Selecting one value may thus be equivalent to selecting several records in the loaded table.


Here we are automating the selection by each line through the macro in button action. This selects each line from Bottom to top.



Sub SelectNext

set mySelections = ActiveDocument.fields(“Id”).GetSelectedValues(1)
set vPosVal = ActiveDocument.fields(“Id”).GetPossibleValues

if mySelections.Count = 0 then
set val=ActiveDocument.Fields(“Id”).GetPossibleValues(vPosVal.count)
ValueToSelect = val.Item(val.Count-1).Text
set val=ActiveDocument.Fields(“Id”).GetPossibleValues
IamDone = ” ”
for i=0 to val.Count-1

ValueToSelect = val.Item(val.Count-1-i).Text

if IamDone = “X” then
exit for
end if

if val.Item(val.Count-1-i).Text = mySelections.Item(0).text then
IamDone = “X”
end if
end if
ActiveDocument.Fields(“Id”).Select ValueToSelect
End Sub

No Comments

Leave a Comment

Your email address will not be published.