Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

input field - set input field values using Macros

Hi all,

I am trying to develop a solution using inputfield but it seems it doesn't work as I need.

In few words, in my app I've declared the input field in the load part and in the front-end the expression is inputsum(inputfieldname).

The user enters the "InputField Total" (ex. 30 000) and the value is distributed proportionaly.

My goal is to make expression 3 editable, which looks like

= sum(DefaultValue) + sum(total<MONTH,FIELD_X,FIELD_Y> inputfield_name - DefaultValue)/12

Capture inputfield example.JPG

Now, only the second expression ( inputsum(inputfieldname) ) is editable.

I'm thinking of create a macro that takes the values from expression 3 and inserting them into the inputfield.

I found something like fld.SetInputFieldCell or fld.SetInputFieldValue, but I've managed to make them work only for static values, not taking into consideration another expression.

Sub SetInputFeild

set fld = ActiveDocument.Fields("inputfield_name")

fld.SetInputFieldValue 0, "999"


Any ideas would be helpful


2 Replies
MVP & Luminary
MVP & Luminary

Re: input field - set input field values using Macros

I don't think that a macro-approach would be useful. Unfortunately I didn't understand what your expression is calculating - you could refer to your input-fields per label/column()/direct expression and also use advanced aggregations with total-qualifier and aggr() functions - but if there are anything else as inputsum() within the expression they wouldn't be editable anymore.

If you need further editable functionalities then you will need to use more inputfields, maybe in another scaling. Inputfields are good for simple use-cases - if it goes to more complex (forecasting) models it will be quite difficult and other solutions might be more suitable: SQL Writeback from QlikView extension object.

- Marcus


Re: input field - set input field values using Macros

I am still unclear what you are trying to do but here is a macro I use with inputfields:

SUB ToggleInputOn2

    SET fx = ActiveDocument.Fields("MitigationID")

     SET fxV = fx.GetSelectedValues  

    if fxV.Count=1 then                  

      set fld = ActiveDocument.Fields("Checked")
      fld.SetInputFieldValue ((fxV(i).Text)-1),"YES" 

    end if              


This one checks that there is just one selected value in the field MitigationID.  If there is then it sets the field Checked to YES.

In my front end if the value of the input field =YES it displays an image of a check in the straight table Chart column

I also use this to toggle all checks on or off:

sub SetEm

      set fld = ActiveDocument.Fields("Checked")

      for a=0 to 62

           fld.SetInputFieldValue A,"YES"



sub ClearAll

      set fld = ActiveDocument.Fields("Checked")

      fld.ResetInputFieldValues 0, 0 ' 0 = All values reset, 1 = Reset Possible value, 2 = Reset single value

end sub

I hope this helps.  If not please give more details on what you are looking for.

Also I have heard that Macros will not be continued in QV 12 - not sure if that's true just mentioning what I heard.