Problem with "greater than or equal to" - InfoPath Dev
in

InfoPath Dev

Problem with "greater than or equal to"

Last post 01-16-2015 07:48 AM by Hilary Stoupa. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 01-15-2015 07:10 AM

    Problem with "greater than or equal to"

    I am a complete newbie with InfoPath, and aa anti-guru with software in general! However, I have designed a simple form (from an original WORD document) that I want to use when servicing patient weighing scales.

    This involves putting a weight on the scale, taking the reading, working out the difference between the two and comparing the result with the allowable tolerance, then noting a "pass" or "fail".

    So I have 4 fields; field 1 (text box, formatted as decimal to three places) = the actual weight, field 2 (text box, formatted as decimal to three places) = the reading, field 3 = the tolerance and field 4 = "pass or fail".

    The rules I have attached to field 2 (as this is the one that changes) are: "Field 3 >= (field 1 - field2), then update field 4 with "Pass". If field 3 < (field 1 - field 2), then update field 4 with "Fail".

    All works well as long as field 1 (the actual weight) is 32 or less. Above 32, and when the difference equals the tolerance, it puts "fail" in field 4.

    Have I done something very silly? Help!!

    Geoff

    Filed under:
  • 01-15-2015 07:36 AM In reply to

    Re: Problem with "greater than or equal to"

    What are the values for field 3 and field 2 in these cases?

    Hilary Stoupa

  • 01-15-2015 07:53 AM In reply to

    Re: Problem with "greater than or equal to"

    As it happens, fields 1 & 2 are in kilograms, and field 3 is in grams, so when I calculate the difference between 1 & 2, I multiply the answer by 1000 in order to compare it with the tolerance.

    In terms of the actaul values involved, it doesn't seem to matter in terms of the results I'm getting. It's when the difference equals the tolerance and field 1 is greater than 32.

    So for example, a weight of 60kg giving a reading of 59.94kg would have a difference of 60g, which is equal to the tolerance of 60g, but gives a "fail".

  • 01-15-2015 08:24 AM In reply to

    Re: Problem with "greater than or equal to"

    Well - it isn't like "32" is some magic number where everything breaks, so there must be something else going on. :)

    One thing maybe worth noting is that just formatting a control to display only 3 decimal points may not mean the actual value is 3 decimal points. Kind of like in Excel - you can format a cell to display only 3 decimal points, but if the real value is 1.234567, that's what Excel will operate with.

    If you want, attach your form under the Options tab in a reply and I'll take a look.

    Hilary Stoupa

  • 01-16-2015 03:37 AM In reply to

    Thanks Hilary - I really appreciate your help. Just for your information, I also tried formatting the fields with the decimal set to "Auto", and still had the same results.

    Please find the form attached.

  • 01-16-2015 06:57 AM In reply to

    Re: Problem with "greater than or equal to"

    Hilary

    My apologies - I should have explained that the vaues change depending on which model you select. I have been basing everything on Model "MS4201", so if you select that model, it will populate the relevant fields. Once this problem is solved, I'll sort out the other model numbers.

  • 01-16-2015 07:10 AM In reply to

    Re: Problem with "greater than or equal to"

    Thanks! Okay, so I am not the mathiest sort of person, so I need a little remedial help to understand what's wrong. I previewed the form and selected the model number, then filled out the Reading column.... what's a good example that show this not working? Maybe attach a screenshot for me? Because I think what you want is for it to pass if the error is within the range of the prechange error (+ or -). And when I preview the form, that seems to be working, so I obviously still don't understand the desired outcome. :)

    Hilary Stoupa

  • 01-16-2015 07:26 AM In reply to

    Re: Problem with "greater than or equal to"

    Okay - the problem occurs when the difference is equal to the tolerance, as long as the "actual" weight is above 32. So on my form, (and this is down to our wonderful weights and measures people!!), when the actual weight is up to 20kg, the tolerance is 20g; when the actual weight is above 20kg, the tolerance is 60g.

    So if you enter a reading of 19.98kg against the actual weight of 20kg, the difference (shown as the error) is 20g, and it passes. If you enter a reading of 49.94kg against an actual of 50kg, the error is 60g which should produce a "pass" but in fact produces a "fail".

    I tested all sorts of weight values, which is when I found that a reading of 31.94kg against an actual of 32kg (difference 60g) gives a pass, whereas a reading of 32.94kg against an actual of 33kg (difference 60g) gives a fail.

  • 01-16-2015 07:48 AM In reply to

    Re: Problem with "greater than or equal to"

    Thanks for the details. I put a calculated value on your form with this formula:

    (my:Acc4 - my:AccRead4) * 1000

    I formatted the calc'd value to display the XML value, so I'd see exactly what IP is working with. Then I previewed, and changed Acc4 to 33. See the attached screenshot. You may need to use a substring function to trim these numbers down when you do your comparison in your rules.


    Hilary Stoupa

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