7 Replies Latest reply: Oct 13, 2011 4:12 PM by Matt Kitchen RSS

    Help with Buttons

      I have set up a 3 buttons to help select a few standard selections from a list boxes. An example would be a button called “North America”, “International”, and “Global”.

       

      “North America” (Button 1 Green Color)

      Actions

      Select in Field – Field = CompanyCode, Search String= (5,60,120,210,240,243,303,399)

      Set Variable – Variable=VRegion, Value = “North America”

      Layout

      Conditional = IF($(vRegion) <> ‘North America’,1,0)

       

      “North America” (Button 2 Blue Color)

      Set Variable – Variable =VRegion, Value = “North America”

      Layout

      Conditional=IF($(vRegion) = 'North America',1,0)

       

      The purpose of two buttons is a visual indicator of the current selection based on color

       

      “International” (Button 1 Green Color)

      Actions

      Select in Field – Field = CompanyCode, Search String= (5,60,120,210,240,243,303,399)

      Select Excluded – Field =CompanyCode

      Set Variable – Variable=VRegion, Value = “International”

      Layout

      Conditional = IF($(vRegion) <> ‘International’,1,0)

       

      “International” (Button 2 Blue Color)

      Set Variable – Variable=VRegion, Value = “International”

      Layout

      Conditional=IF($(vRegion) = ' International,1,0)

       

      “Global” (Button 1 Green Color)

      Actions

      Select in Field – Field = CompanyCode, Search String= Left Blank

      Set Variable – Variable=VRegion, Value = “Global”

      Layout

      Conditional = IF($(vRegion) <> ‘Global’,1,0)

       

      “Global” (Button 2 Blue Color)

      Set Variable – Variable=VRegion, Value = “Global”

      Layout

      Conditional=IF($(vRegion) = ' Global,1,0)

       

      The buttons work get as long as someone only uses these three buttons for selections but as soon as the clear button or the list box is used to make a selection the color coding of the buttons stops working. This happen because the variable is still set from the last button pushed even though the selected fields have changed using a list box on been cleared. Any idea how to fix this?

        • Help with Buttons
          John Witherspoon

          I've needed to create an example file for some time, so I'm going to go do that and then post it.  But in short, you set an additional variable, such as vNorthAmerica to getcurrentselections().  Then you base the color on whether or not getcurrentselections() returns the same value as what is in vNorthAmerica.

           

          I've done this with macros in a live application.  I need to see if it works with actions too, though it's a little riskier, as I don't think there's any guarantee on a multi-core machine that the selections will be set before you set the variable.

          • Help with Buttons

            John,

             

            First off thanks for the help and the great example you provided. This has given me so much more than what I was asking for. I am not very experienced in macos so it’s going to take me a little bit to apply this in my app but it look like it will work. Your formatting the color with an expression vs my hiding and reappearing buttons is so much better. 

            I do have one additional question because of my lack of experience with macros. In your example how would I select “Type A” and “Type C” by excluding “Type B”? I want to accomplish this through exclusion because eventually I could add a “Type D” and “Type F” which I would want selected as well. 

             

            Thanks again for the help.

              • Re: Help with Buttons
                John Witherspoon

                You select the value(s) you want excluded, then select the excluded values.  Like this:

                 

                set field = activedocument.fields("Type")
                field.select "Type B"
                field.selectexcluded

                  • Re: Help with Buttons

                    John,

                     

                    Your solution works but I am not 100% there. In your example I want to use the buttons to make selections for "type" only without resetting selections in "status" or "product". I would also like to be able to make selections in all list box except "Type" after a button has been used to set the "type" and keep that type's button color as active=green.

                     

                    Examples:

                     

                    Click button "Type A" it selects "Type A" in Type list box and the button turns green.

                    Select "Status L" from the Status list box and the "Type A" button stays green.

                     

                    Clear all selections and button "Type A" turns back to grey.

                     

                    or

                     

                    Select "Product X", "Product Y", and "Status L"

                    Click button "Type A" and "Type A" is selected from the list box button turns green and your selections "Product X", "Product Y", and "Status L" stay active.

                     

                    Not sure this is possible.

                     

                    Thanks

                      • Re: Help with Buttons
                        John Witherspoon

                        My macros are clearing all selections at the beginning.  Don't do that.  You can also get selections for a specific field instead of all selections.  So if you want a "not Type B" button, skip the clear, and then set the variable to only the selections for the Type field.

                         

                        So for instance, in what I posted, I can replace the CZ macro with this:

                         

                        sub CZ
                            activedocument.fields("Type").select "Type B"
                            activedocument.fields("Type").selectexcluded
                            activedocument.variables("CZ").setcontent activedocument.evaluate("getfieldselections([Type])"),false
                        end sub

                         

                        And it won't clear, will only set the type field, and then will only care about the type field when dealing with the color of the associated button.

                         

                        Edit:  Oops, need to change the button color expression to match.  This should work:

                         

                        if(getfieldselections([Type])=CZ,lightgreen(),lightgray())

                          • Re: Help with Buttons

                            John it’s been a while and I am looking to expand on my button selections. Below is my example following our previous examples. I would like to a button to stay green until something is selected in “Type” filed then turn grey. The button works for clearing the type filed however the color doesn’t and I have a feeling it’s not working because no value is set.

                             

                            sub All
                                activedocument.fields("Type").clear
                                activedocument.variables("vAll").setcontent activedocument.evaluate

                            ("getfieldselections([Type])"),false

                            end sub

                             

                            Button Color.

                            if(getfieldselections([Type])=vAll,lightgreen(),lightgray())

                             

                            I was trying to avoid listing all types since they are continually being added.