View Full Version : Syntax problem on merge from Access


CEH
05-18-2007, 05:56 AM
Having a problem with getting the format correct in a Word document when pulling the info from Access..... This is the common "Merge to Word" code..... One of my fields in Access is currency. In Access I have it set to "currency" decimal at 2.. BUT..... with this code.......

WordObj.Selection.GoTo what:=wdGoToBookmark, Name:="BkMark7"
WordObj.Selection.TypeText [txtBidAnnual]

It shows up in the Word document with 3 digits after the decimal.
So.... Question is... Where do I add the formating in Word to correct this? And.... I actually would like to round this figure to nearest dollar when it shows up in the Word document. Is there a way of doing that in Word?

Thanks

CEH
05-21-2007, 07:27 PM
OK...... in case anyone is looking to do this one and having the same problem I'll post the solution......

WordObj.Selection.GoTo what:=wdGoToBookmark, Name:="BkMark7"
WordObj.Selection.TypeText (Format(Nz([txtBidAnnual], 0), "$#,#"))
for NO decimal places

or

WordObj.Selection.GoTo what:=wdGoToBookmark, Name:="BkMark7"
WordObj.Selection.TypeText (Format(Nz([txtBidAnnual], 0), "$#,##0.00"))
for 2 decimal places..........

"txtBidAnnual" being the field containing my dollar amount to show in my Word document.