Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I have the following problem: I have two listboxes: Code and Cost Center and I want when I make selection in Cost Center a several codes to be selected in Code list box.
I decided to make a macro:
sub SelectFirstLevelCodes
set CodeField = ActiveDocument.Fields("AccountCode")
set CostCenterFirstLevelField = ActiveDocument.Fields("CostCentersFirstLevel").getSelectedValues
for i=0 to CostCenterFirstLevelField.Count - 1
if CostCenterFirstLevelField.Item(i).Text="FirstCC" then
CodeField.Select "1*"
end if
if CostCenterFirstLevelField.Item(i).Text="SecondCC" then
CodeField.Select "2*"
end if
if CostCenterFirstLevelField.Item(i).Text="ThirdCC" then
CodeField.Select "3*"
end if
next
end sub
and it is working, except that I can select only one Cost Center. If I select two, Codes are selected only for the last selected CostCenter, not for both. How can I avoid this problem?
Hi there,
Luckas, I don't want to use a button with an action for selection. The idea is when I choose lets say FirstCC from a listbox in another listbox dynamically to be choosen let's say 100 values starting with 1 (100, 101, 102, etc.) I think that answers blase question, too. (May be blase didn't see the * after the digits)
I found a solution and it was to use "ToggleSelect", instead of "Select" and also had to add "CodeField.clear" before the loop so that it deselects the codes when I deselect the Cost Center.
Hi there,
can you please take a look at this post and let me know if this what you try to achieve?
http://community.qlik.com/forums/t/25932.aspx
Thanks.
Lukas
May I ask why you dont join an inline table to your data tables instead.
CostCenterLevel:
LOAD * INLINE [
CostCenterFirstLevel,CodeField
FirstCC,1
SecondCC,2
ThirdCC,3
];
Otherwise (using your code) try changing the .Select to .ToggleSelect. Make sure to do a Field.Clear first, above the loop.
Hi there,
Luckas, I don't want to use a button with an action for selection. The idea is when I choose lets say FirstCC from a listbox in another listbox dynamically to be choosen let's say 100 values starting with 1 (100, 101, 102, etc.) I think that answers blase question, too. (May be blase didn't see the * after the digits)
I found a solution and it was to use "ToggleSelect", instead of "Select" and also had to add "CodeField.clear" before the loop so that it deselects the codes when I deselect the Cost Center.
Sorry for not seeing the wildcards. If you do a left(AccountCode,1) as key_AccountCode you can use my suggestion. Worth i try if the data is rather small or you do other "non qvd optimized" conversions.