Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SetInputFieldCell usage

Hello.

I need to write a macro to initialize input fields to some values (ex: set a budget according to real values from previous year). I wrote the following code, but it does not work. Writing the same constant value in the input fields is ok, but when I try to set it to the value coming from another cell it fails. I also tried using two different tables, no way..... The macro works for the first value, then it crashes.

Thanks!
Paolo


Sub ResetInputFields
on error resume next
set budget = ActiveDocument.GetSheetObject( "BUDGET" )
for RowIter = RowIter to budget.GetRowCount-1
rif = budget.GetCell(RowIter,2).Number
budget.SetInputFieldCell RowIter,1,rif
next
End Sub
















3 Replies
biester
Specialist
Specialist

Ciao Paolo,

I tried around a little and found out the following.
First: if you have not suppressed the header row in a table box, GetRowCount delivers the number of data rows+1. If you have e. g. 5 data rows, GetRowCount delivers 6 if header row not suppressed. So to read the desired cellvalue (with header row NOT suppressed!!), you have to pick cell values from 1 (0 is the header row) to GetRowCount-1 (which in my example is 5).
Second: the inputfield rows do NOT count the header row !! That means to set the value of the inputfield of the first data row to the value of column 3 of the SAME data row you must in your example use "budget.SetInputFieldCell 0, 1, budget.Cell(1,2).Number!
It's a bit ***, but it's important to note the difference in row handling betwen inputfields and "normal fields" and the header row problem. I have enclosed a small example in which the thing should work. Hope its understandable and helps,

Saluti,
Joachim

Not applicable
Author

Ciao Joachim,

yes, this brings me much closer to the solution. My object is actually a Pivot Table and in this case this is not yet working. But now I think I can handle that.

Thanks! Bye.

Paolo

Not applicable
Author

Thanks for helping me out with that! I was getting so frustrated with setinputfieldvalue on a tablebox!