change button - InfoPath Dev
in

InfoPath Dev

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

change button

Last post 09-28-2011 11:05 AM by Doreen. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-28-2011 08:11 AM

    • Doreen
    • Top 50 Contributor
      Female
    • Joined on 08-11-2010
    • Federal Way, WA
    • Posts 272

    change button

    I need help figuring out how to make a button switch back and forth between two values in a text box.  When 1st value is displayed, click button and the  2nd value is displayed.  When 2nd value is displayed, click button and 1st value is displayed again and so on.

    The value in the text box is determined when a certain combination of radio buttons is checked. There are 2 sets of 2 (Yes/No) radio buttons.  If yes and yes are checked then value1 appears in text box.  Any other combination (yes/no, no/yes or no/no) then value2 appears in text box. 

     The idea is the user answers two question to determine the value but they are also given ability to change the answer if they want to.  So I'd also like to clear the radio buttons when the switching (change button is clicked) occurs.

     I can get the button to clear the radio buttons and I can get the text box value to change once, but on 2nd and subsequent clicks, it doesn't change back again.

         For the switch rules on the button I have 2 rules:

            Rule 1 - if textBox = value1, set textBox value = value2

            Rule 2 - if textBox = value2, set textBox value = value1

        For the clear portion of the button I have 1 rule

             Rule 3 - if radioButton1 is not blank, or radioButton2 is not blank, set radioButton1 = ", and set radioButton2 value = ""

     Any suggestions?

  • 09-28-2011 08:49 AM In reply to

    The approach you're describing should work.  Must be some small detail that's messing things up.  Could you attach an example of an XSN where this isn't working?

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 09-28-2011 09:04 AM In reply to

    • Doreen
    • Top 50 Contributor
      Female
    • Joined on 08-11-2010
    • Federal Way, WA
    • Posts 272
    Ok the xsn file was too large to attach so I removed some sections leaving only those sections that pertain to the problem.
  • 09-28-2011 10:32 AM In reply to

    Ok, the issue here is that you have some pretty convoluted logic going on.  You have rules on all of the option buttons and rules on the textbox and through their interaction, you are winding up with the result you are seeing.

    It may be sub-optimal, but how about adding a Process button that determines the outcome when it's clicked, instead of having rules on all the various fields?

    Another issue on the button you have is that the first rule can change the field from Local to Non-local, and then the second rule sees that the value is Non-local and then changes it back to Local.

    To prevent this, you can make use of the "Don't run remaining rules if the condition of this rule is met" option.  This can prevent the rule that resets the option buttons from firing, so you'll want to move that up to be the first rule on the button.

    Jimmy Rishe / Software Developer / InfoPath MVP
    Qdabra Software
  • 09-28-2011 11:05 AM In reply to

    • Doreen
    • Top 50 Contributor
      Female
    • Joined on 08-11-2010
    • Federal Way, WA
    • Posts 272

    Thanks your suggestion worked!  I moved the clear radio buttons rule to the top of the rules list.  For the 2 switch rules (now 2nd & 3rd in line), I checked "Stop processing rules when this rule finishes".

    The reason I have the same rules on both radio buttons and the text box is because it's the only way I can get the correct value to appear in the textbox.  I tried puting the set of rules to on only one control initially (then moving it to various controls) but it won't  fire - it only fires when the exact same rules are applied to all controls involved.

     Thanks again for taking the time to venture into this!


    Doreen

Page 1 of 1 (5 items)
Copyright © 2003-2012 Qdabra Software. All rights reserved.
View our Terms of Use.