Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This code:
sub test
set hash_key = ActiveDocument.Fields("trans_hash_key").GetPossibleValues(100000)
set itemno = ActiveDocument.Fields("lime_itemno").GetPossibleValues(100000)
for i = 0 to hash_key.count - 1
msgbox itemno(i).text ' Error here after 5 loops!
next
end sub
loops through my data for about 5 times (there is totaly 10 rows of data to be read), and then suddenly stops with the errormessage Invalid procedure call or argument marking the row msgbox itemno(i).text
What can be wrong? My first guess was that the data in itemno(5).text was corrupt somehow, but when i selected only this row on this item in qlikview and run the test macro again, the macro runns ok without any errors...it seems like there is some buffer error or such.
Any ideas anyone?
Try displaying hash.key.Count and itemno.Count in msgbox's. They must be exactly equal for your example to work. In which case why not use itemno.Count the limit variable?
-Rob
Thanks for your reply. Let me explain more about this problem:
My example was a simplified example. I actually need to get 4 columns from my table like this:
set hash_key = ActiveDocument.Fields("trans_hash_key").GetPossibleValues(100000)
set period = ActiveDocument.Fields("trans_period").GetPossibleValues(100000)
set qty = ActiveDocument.Fields("lime_qty").GetPossibleValues(100000)
set itemno = ActiveDocument.Fields("lime_itemno").GetPossibleValues(100000)
for i = 0 to hash_key.count - 1
msgbox "hash " + hash_key(i).text
msgbox "item " + itemno(i).text
msgbox "period " + period(i).text
msgbox "qty " + qty(i).text
next
This generates the error I was talking about earlier.
If I change the code to this and have itemno as limit variable:
set hash_key = ActiveDocument.Fields("trans_hash_key").GetPossibleValues(100000)
set period = ActiveDocument.Fields("trans_period").GetPossibleValues(100000)
set qty = ActiveDocument.Fields("lime_qty").GetPossibleValues(100000)
set itemno = ActiveDocument.Fields("lime_itemno").GetPossibleValues(100000)
for i = 0 to itemno .count - 1
msgbox "hash " + hash_key(i).text
msgbox "item " + itemno(i).text
msgbox "period " + period(i).text
msgbox "qty " + qty(i).text
next
Then I get no errors, but the data is messed up like this:
This is an example data
hash_id itemno period qty
1 A 2 12
2 B 1 18
Then, my messageboxes from my second code example looks like this:
"hash 1" -> "itemno A" -> "period 1" -> "qty 12"
"hash 2" -> "itemno B" -> "period 2" -> "qty 18"
Which is wrong. Period is displayed on the wrong itemno. It seems like Qlikview is considering my 4 fields like 4 differnt tables, not linked togeter, and sorted separatly ascending....
/Robert