Help with calculations - InfoPath Dev
in

InfoPath Dev

Help with calculations

Last post 06-28-2012 04:50 AM by Kazzahere. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 06-15-2009 05:36 AM

    Help with calculations

    I have a little section of calculations, very simple nothing to complicated but somehow it isn't working. (I also have hidden fields to help set these correctly SetQuant and SetFootage) Its also set up to keep the boxes filled with 0 in case it is blank so the calulations will work with rules.  Txtbox A will always calculate first over txtbox B if txtbox A is 0, then txtbox B calcuates.  If category of 8 is chosen, only txtbox B will calculate.

    txtboxA Rules = conditions= category is not equal to 8 or txtboxA >0 and TxtboxB >0= total value

    TxtboxA *TxtboxC=Totalvalue

    txtboxB Rule1= conditions = Category is equal to 8 or txtboxA >orequal to 0 = total value

    TxtboxB*TxtboxC=TotalValue

    Rule 2 - if txtbox A is equal to 0

    Set fields value of hidden box set footage value into the total value box.

    This works just fine but what if a person made a mistake and they make one of the boxes blank, and it goes back to 0, it will not recalculate the txtboxB by default, the total value does not refresh.  I do not have programming and hoping this is simple to make it where if txtbox is = to 0, that it would force txtbox B to calculate but it doesn't.  I will send a copy of form if needed I have been at this for a while and I am at my last ends wits to get this figured out... I hope i explained this ok.

  • 06-15-2009 09:01 AM In reply to

    Hi --

    One thing that often trips people up with rules is that a field has to change for the rule to fire, and the rule that is bound to a field will only fire if that field changes. When you say 'if a person makes a mistake and makes one of the text boxes blank', which text boxes are you concerned with? One that takes a value that is used in your calculations? Or one that displays a result? If it is the ones that display the result, change those to expression boxes, so the user can't change them by mistake. If it is any of the fields used in calculations, you'll need to add rules to those fields that will recalculate your values, and those new rules could have the condition 'if field is blank', with some special logic to work around the scenario. Let me know if you need more info....

    Hilary Stoupa

  • 06-15-2009 11:00 AM In reply to

     

    Yes i finally got it what I needed to do, I realized that it was in the wrong text box and now its works smoothly when you said this "the rule that is bound to a field will only fire if that field changes."  Thank you for your time!
  • 06-15-2009 01:48 PM In reply to

    Oh, I'm glad that worked for you. I find that it can be easy for people to confuse default value behavior with rule behavior. It took me a while before it really sunk in, but once I realized that the field with the rule on it has to change for a rule to fire, it got a lot easier....

    Hilary Stoupa

  • 03-21-2012 05:30 AM In reply to

    Hi Hilary

    That's a really useful post, thanks.

    Do you know if there is any way of adding a rule so that if the user changes a field used in a calculation the resulting field updates. I have managed to create a rule for if the user deletes the entry no result is shown but I cannot suss out how to get the final figure to update if they change their original entry.

     Thanks

    Karen

  • 03-21-2012 02:41 PM In reply to

    Generally, your options are to create rules on all the fields used in the calculation - so if any of them change, the rules fire to update the target field - or to use default values. Usually, for a calculation, a default value (or even an expression box, if you don't need to save the value of the field) work well.

    Hilary Stoupa

  • 06-14-2012 06:33 AM In reply to

    Hi Hilary

    I am now on a different form but am having a similar problem. Thanks your last post helped me with that problem.

    I have 2 fields e.g. hours worked and weeks worked. I have numberous rules on weeks worked to provide calculations which are fine, if the user changes weeks worked the formulas update. If the user changes hours worked though as the rules aren't on that field the totals do not update. I have tried duplicating the rule so it applies to both fields but it still doesn't update.

    Can you offer any light on this please.

    Thanks

    Karen

  • 06-14-2012 09:04 AM In reply to

    You would have to have rules on the Hours fields as well. Is that what you did? Did you copy the rules using the IP 2010 functionality? Sometimes it does some unexpected stuff with the XPath - you may want to check the rules on your Hours field. It also seems like you may want to consider default values here instead of rules, if possible.

    Hilary Stoupa

  • 06-28-2012 04:50 AM In reply to

    Thanks again.

    What had happened when I copied the rules it changed one of the fields so it wasn't running as I expected.

    Am using rules as there are some conditions.

    Something so simple but never crossed my mind that when copying a rule it could change.

    Thanks

    Karen

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