Avatar of vikasbapat
vikasbapat

asked on 

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,
Microsoft Word

Avatar of undefined
Last Comment
vikasbapat
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

You  can use the  ROUND Function in a formula field:

{=ROUND({MERGEFIELD FieldName} , 2)}
Avatar of vikasbapat
vikasbapat

ASKER

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,
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of vikasbapat
vikasbapat

ASKER

Hello,
It worked this time.
\#"0.000#" - this was useful.
Thanks for your quick support.

Thanks,
Avatar of vikasbapat
vikasbapat

ASKER

Hello,
It worked this time.
\#"0.000#" - solved the issue..

Thanks,
Microsoft Word
Microsoft Word

Microsoft Word is a commercial document editing program that is part of the Microsoft Office suite. It features numerous text-editing tools for creating richly formatted documents, along with tools for the use of macros in Word documents. Word's native file formats are denoted either by a .doc or .docx file extension. Plugins permitting the Windows versions of Word to read and write formats it does not natively support, such as the OpenDocument format (ODF) are available. Word can import and display images in common bitmap formats such as JPG and GIF. It can also be used to create and display simple line-art.

30K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo