Data validation with decimal values in data source

M

Miguel Isidoro

Hi,

In a InfoPath form, I am using a data validation rule where I compare two
values and if they don't match I show a error message. I have two textboxes
with similar expressions and data formatting settings that basically perform
a sum of values in 2 repeating tables. The problem I am having is that one is
storing the value with only 2 decimal places and the other is storing the
value with much more. Ex: instead of comparing 12,13 with 12,13 which would
not trigger a data validation error I am comparing 12,13 with 12,1299999999
because the second textbox is storing the value in its data source field with
more than 2 decimal places and the first textbox with only 2 decimal places.
The strangest thing is that the values from which the sum value is being
calculated are 4,20 and 7,93, both with only 2 decimal places. The display
value is however correct in both textboxes because of the data formatting
settings that are set to display 2 decimal places. Is there any way to use a
rule that makes a round of both values to the second decimal place so that i
can compare similar values (in my previous example 12,13 to 12,13) or to
prevent the values to be stored in the data source with more than 2 decimal
values?

Thanks,
Miguel
 
S

Shiva (GGK Tech)

Hello,

If we specify any specific decimal formatting for any field it should be
applicable for look and feel but at the end storing in .xml(file) is
different. For example, If you specify to display after decimal display only
2 numbers then we enter like 12.4567 then it will round to “12.34†in
InfoPath form but storing in .xml is “12.4567â€. To avoid this we need to add
the rule for that filed to store which format of value you want to store in
that field.

We have “ceiling†and “round†functions for rounding the decimal value in
InfoPath.
 
S

Swathi (GGK Tech)

Hi,
You can prevent the values storing in database with more than 2 decimal
places by giving the data type for the field decimal[ (precision, scalar).
Here precision is the number of digits you want to place before the decimal
point and scalar is the number of digits you want to place after the decimal
place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top