Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

InputField Macro

Hey Community,

i use this macro

26. To reset InputField values

Sub ResetInputField

' Reset the InputField

  set fld = ActiveDocument.Fields("InputFieldName")

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

End Sub

From Useful Qlikview Macros

My Question is how can i rest more then one field ?

And in one button to rest all my field to the last data from DB

Thank

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

24 Replies
Gysbert_Wassenaar

It may be easier to remove all the data using the Reduce Data -> Remove All Values option from the File menu and then reload the document like I mentioned in this post: Re: InputField‌.

If you insist on macro's then you need to loop through a list of field names and call the ResetInputField subroutine with each field name as a parameter. Perhaps something like this:

Sub ResetInputField(strFieldName)

  set fld = ActiveDocument.Fields(strFieldName)

  fld.ResetInputFieldValues 0,  0

End Sub

Sub ResetAllInputFields

     set flds = ActiveDocument.GetFieldDescriptions

     for i = 0 to flds.Count - 1

         set fld = flds.Item(i)

         if fld.IsInputField then ResetInputField(fld.Name)

     next

End Sub


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Thank you again for you help, my client didn't want the first solution you gave me, the request is on button that will rest all my input field

Capture.JPG

On your macro i can use only one field (in my pic i have mroe then one, mark in yellow )

Sub ResetInputField(strFieldName)

  set fld = ActiveDocument.Fields(strFieldName)

  fld.ResetInputFieldValues 0,  0

End Sub

set flds = ActiveDocument.GetFieldDescriptions

for i = 0 to flds.Count - 1

    set fld = flds.Item(i)

    if fld.IsInputField then ResetInputField(fld.Name)

next

tamilarasu
Champion
Champion

Hi David,

You can use below macro to reset all the input fields in single click. Attached sample for your reference.

Sub ResetInputField

fldArray= Array("Budget","Status","Date")  // Your input field names

For i=0 to UBound(fldArray)  

  set fld = ActiveDocument.Fields(fldArray(i))

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

Next 

End Sub

Gysbert_Wassenaar

Then you're executing the wrong sub with your button.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

its work but when i do reload it failed Capture.JPG

Anonymous
Not applicable
Author

I use only one sub

Anonymous
Not applicable
Author

Sub ResetInputField(strFieldName)

  set fld = ActiveDocument.Fields(strFieldName)

  fld.ResetInputFieldValues 0,  0

End Sub

Sub ResetAllInputFields

     set flds = ActiveDocument.GetFieldDescriptions

     for i = 0 to flds.Count - 1

         set fld = flds.Item(i)

         if fld.IsInputField then ResetInputField(fld.Name)

     next

End Sub

tamilarasu
Champion
Champion

There is something wrong in your load script. The above macro is not related with the load script. You can check the log file to identify the issue.

tamilarasu
Champion
Champion

Like attached.?