Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

An Issue with VBA macro in QV

Hi everyone.

In attached file I have macro. This macro needs to be used with button "Continue" at the firtst tab. Now, when I push this button it is expected that the second tab will be open and value "4" will be selected in the list box. But instead of it, when I press the button, no value has selected.

There is some mistake in code but I don't get where?

Script:

LOAD * INLINE [

    TOP

    2

    3

    4

    5

    10

    20

];

Macro:

sub select_first

set vvv_var = ActiveDocument.Variables("v_active_select_first")

vvv_varcont = vvv_var.GetContent.String

if vvv_varcont = "1" then

vvv_var.SetContent "0", true

ActiveDocument.Fields("TOP").Select "4"

end If

end sub

By default: v_active_select_first = 0

1 Solution

Accepted Solutions
m_s
Partner - Creator II
Partner - Creator II

Hello Nataliia,

you don't need to use a macro for this, you can simply add a second action that will select inside the TOP field. I re-attached your app so you can take a look at it.


Also your macro did not select a value because you check if the content of the variable "v_active_select_first" is set to "1" (it was set to "0"). After manually setting it to "1" (via Variable Overview) your macro works.

Mathias

View solution in original post

2 Replies
m_s
Partner - Creator II
Partner - Creator II

Hello Nataliia,

you don't need to use a macro for this, you can simply add a second action that will select inside the TOP field. I re-attached your app so you can take a look at it.


Also your macro did not select a value because you check if the content of the variable "v_active_select_first" is set to "1" (it was set to "0"). After manually setting it to "1" (via Variable Overview) your macro works.

Mathias

Peony
Creator III
Creator III
Author

Oh! You are right, Mathias. It's all about variable state.

Thank you for your explanation and example. It really helps. Everything is clear now.