2 Replies Latest reply: May 11, 2011 3:31 PM by Therese Liebermann RSS

    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