5 Replies Latest reply: Apr 27, 2009 1:06 AM by Jay Jakosky RSS

    Macro

      Hi Everyone,

      I need a help on macro.

      I have two tabs in one report. I have selection boxes on both tabs. When I move from first tab to second tab, I need to clear the selection boxes.I did that using the below macro,

      sub Clear
      ActiveDocument.Fields("F1").clear
      end sub

      Now, when I move back to first tab, I need the same selection which I selected previously (prior to moving to second tab). could someone help me with the macro.

      Ex: I clear the selection made on "F1", when I move to 2nd tab. I need the selection made on "F1" to be present, when moved to 1st tab.

      Please see the attachment

      Pascal

        • Macro

          Hello Pascal,

          Using a public variable should do the trick:

           

          Public Selection

          sub AwayFromTab1
          set Selection = ActiveDocument.Fields("F1").GetSelectedValues
          ActiveDocument.Fields("F1").clear
          end sub


          sub BackToTab1
          set f1 = ActiveDocument.Fields("F1")
          f1.SelectValues Selection
          end sub


          I hope this helped you out.

          Mark

          • Macro
            Jay Jakosky

             

            Public selarr()

            Public fldarr()

            Public valcount

             

            sub LeaveTab

            valcount=ActiveDocument.Fields("$Field").GetCardinal

            set vals=ActiveDocument.Fields("$Field").GetPossibleValues

            Redim selarr(valcount)

            Redim fldarr(valcount)

            for i=0 to valcount-1

            fldarr(i)=vals.Item(i).text

            set selarr(i)=ActiveDocument.GetField(vals.Item(i).text).GetSelectedValues

            next

            ActiveDocument.clearAll false

            end sub

             

             

            sub ReturnToTab

            for i=0 to valcount-1

            ActiveDocument.GetField(fldarr(i)).SelectValues selarr(i)

            next

            end sub