开发者

Using decimal/money field types in InfoPath 2010

I'm building a form that contains a large number of fields that will hold money values - for some bizarre reason I can't quite comprehend, InfoPath 2010 doesn't provide a "decimal" or "money" field type to use, out of the box. (The decimal type provided has (double) in brackets next to it, which indicates to me it will be stored using floating point arithmetic).

If I create a xsd from scratch and use that to create a form in InfoPath, it accepts <xsd:decimal> without issue, but I am no longer able to add fields from within infopath, which is frustrating.

So my question is, is there any way to use decimal/money types in InfoPath 2010 without resorting to writing my own xsd -or- is there some way to allow myself to add new fields after creating an InfoPath fo开发者_开发百科rm from a xsd?

Some way to "import a custom field type" from an xsd to reuse over and over again in an infopath form would probably also solve the issue - then i could just import a "customType" that is of basetype xsd:decimal and reuse that all over my forms...


Unfortunately it is a problem (for lack of a better term) in XPath (not InfoPath/XML or MS specific). So even if you figured out a way to create your own type I think the processing engine internally would still convert it back to double anytime you tried to access and create the same floating point problems you have now.

Check out this article that uses rounding to solve (sort of) the problem. Not the most elegant solution but I think it is what you are stuck with as far as InfoPath goes. http://blogs.msdn.com/b/infopath/archive/2008/04/17/invalid-data-error-when-calculating-the-result-of-2-or-more-fields.aspx


Create your money field as a textbox. Select the textbox and within Properties select Field Properties. Change the data type to Decimal (double). Then change the Data Format (up in your ribbon) to Number, Decimal places 2. Works like a charm :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜