Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Problems setting a variable to a concatenated string

I need to take the selected values in the l_freq and u_freq, and use them to create a string that will be used as select criteria for another field in the document.  The code I have so far (to build the string, and put the string in a variable) doesn't seem to work.

sub SetLimits()

end sub

When the code gets to the last line, I get an error that says: "Object Required: 'SelectString'

What am I doing wrong?

Oh, and yes, I realize that I can do this in an action, but I ran into problems with things not happening sequentially, so variables were not getting set properly.

Thanks!

dim SelectString

SelectString = ""

ActiveDocument.Fields("l_freq").SelectPossible
ActiveDocument.Fields("u_freq").SelectPossible

set LB = ActiveDocument.getField("l_freq").getSelectedValues()
set UB = ActiveDocument.getField("u_freq").getSelectedValues()

for i = 0 to LB.Count-1
     if i = 0 then SelectString = "("
     SelectString = SelectString & ">=" & LB.item(i).text & "<=" & UB.item(i).text
     if i = LB.Count-1 then
          SelectString = SelectString & ")"
     else
          SelectString = SelectString & "|"
     end if
next

ActiveDocument.Variables("Variable1").setContent SelectString.GetContent.string, true

Tags (1)
1 Solution

Accepted Solutions
erich_shiino
Not applicable

Problems setting a variable to a concatenated string

at the last line you don't need the .getcontent.string

ActiveDocument.Variables("Variable1").setContent SelectString, true

I guess this is because this variable  (SelectString) was only exists in this macro environment.

The other case you were working with an object associated with a document variable.

Hope it helps,

Erich

2 Replies
erich_shiino
Not applicable

Problems setting a variable to a concatenated string

at the last line you don't need the .getcontent.string

ActiveDocument.Variables("Variable1").setContent SelectString, true

I guess this is because this variable  (SelectString) was only exists in this macro environment.

The other case you were working with an object associated with a document variable.

Hope it helps,

Erich

Not applicable

Problems setting a variable to a concatenated string

Yep, very much so!  Thanks!