• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

How to work with rounding values in MS Word Merge fields

Hello,

I'm developing a form in MS Word. I have used merge fields to bind the values from database. For this I'm using SQL Server 2005.
Merge field may return values like (0.125, 0.789, 0.345, 0.1258)
My issue is - when I get any values like "0.1258" for the merge field (i.e. from database), in MS Word its automatically rounding up to "0.126" .
To resolve this issue I have used Field code as :
MERGEFIELD FieldName {IF {MERGEFIELD FieldName\#"0.0000"}="0.1258" "0.1258" "{MERGEFIELD FieldName}" }
This is giving me correct result as - 0.1258. But values like 0.125, 0.789 are coming up as 0.1250, 0.7890.
How can I get rid of these extra zero in "0.1250"?


Thanks,
0
vikasbapat
Asked:
vikasbapat
  • 3
  • 2
1 Solution
 
GrahamSkanRetiredCommented:
You  can use the  ROUND Function in a formula field:

{=ROUND({MERGEFIELD FieldName} , 2)}
0
 
vikasbapatAuthor Commented:
Hello,
I tried your solution - {=ROUND({MERGEFIELD FieldName} , 2)}
But this did not solve my issue.. I want to show 4 digits after the decimal point.
For which I have used code as - {MERGEFIELD FieldName\#"0.0000"}
And if the value is like "0.123" then it should not come up as "0.1230"

Can u please help on this?

Thanks,
0
 
GrahamSkanRetiredCommented:
Use {=ROUND({MERGEFIELD FieldName} , 4)}  to round to four decimal places.

If you don't want to see the zero in the fourth place, use \#"0.000#" as the format text/.
0
 
vikasbapatAuthor Commented:
Hello,
It worked this time.
\#"0.000#" - this was useful.
Thanks for your quick support.

Thanks,
0
 
vikasbapatAuthor Commented:
Hello,
It worked this time.
\#"0.000#" - solved the issue..

Thanks,
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now