Lose currency formatting when inserting data into Word

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a donations template letter that I have in Word. From access I want to pass the amount and insert it into the lette
using a bookmark. All goes well, but I lose the currency formatting. For numbers 1,000 and above, no comma appears in the word document and I can't figure out why. When I export data from the same table into Excel, I see both the comma and the dollar sign. Can you tell me what is wrong with the code below? Thank you. Mery

Private Sub Donation_Letter_Word_Click(
On Error GoTo Err_Donation_Letter_Word_Clic

Dim oApp As Objec

Set oApp = CreateObject("Word.Application"
oApp.Visible = Tru

Dim curAmount As Currenc
curAmount = Forms![Donor-Registration Form-US]![individual donations subform]!Amoun

' Open Microsoft Word using automatio


oApp.Documents.Add "C:\Windows\Application Data\Microsoft\Templates\RegDonationLetter.dot
oApp.Visible = Tru

' The following code is generated from your Access form while it i
' manipulating an instance of Word
' So, while it looks somewhat like VBA, it's really Word VBA

If oApp.ActiveDocument.Bookmarks.Exists("Amount") = True The
oApp.ActiveDocument.Bookmarks("Amount").Range.Text = curAmoun
End I

Exit_Donation_Letter_Word_Click
Exit Su
 
Meryl,

This is a pure guess!!

Is the Amount field on your subform formatted as currency?

Steve
PC Datasheet


Meryl said:
I have a donations template letter that I have in Word. From access I want to
pass the amount and insert it into the letter
using a bookmark. All goes well, but I lose the currency formatting. For
numbers 1,000 and above, no comma appears in the word document and I can't
figure out why. When I export data from the same table into Excel, I see both
the comma and the dollar sign. Can you tell me what is wrong with the code
below? Thank you. Meryl
Private Sub Donation_Letter_Word_Click()
On Error GoTo Err_Donation_Letter_Word_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Dim curAmount As Currency
curAmount = Forms![Donor-Registration Form-US]![individual donations subform]!Amount

' Open Microsoft Word using automation


oApp.Documents.Add "C:\Windows\Application Data\Microsoft\Templates\RegDonationLetter.dot"
oApp.Visible = True

' The following code is generated from your Access form while it is
' manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word VBA.

If oApp.ActiveDocument.Bookmarks.Exists("Amount") = True Then
oApp.ActiveDocument.Bookmarks("Amount").Range.Text = curAmount
End If

Exit_Donation_Letter_Word_Click:
Exit Sub
 
Yes, it is.
-----Original Message-----
Meryl,

This is a pure guess!!

Is the Amount field on your subform formatted as currency?

Steve
PC Datasheet


news:816B5E7D-A604-4CC8-A80C-
(e-mail address removed)...
I have a donations template letter that I have in
Word. From access I want to
pass the amount and insert it into the letter
using a bookmark. All goes well, but I lose the
currency formatting. For
numbers 1,000 and above, no comma appears in the word document and I can't
figure out why. When I export data from the same table into Excel, I see both
the comma and the dollar sign. Can you tell me what is wrong with the code
below? Thank you. Meryl
Private Sub Donation_Letter_Word_Click()
On Error GoTo Err_Donation_Letter_Word_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Dim curAmount As Currency
curAmount = Forms![Donor-Registration Form-US]!
[individual donations
subform]!Amount
' Open Microsoft Word using automation


oApp.Documents.Add "C:\Windows\Application Data\Microsoft\Templates\RegDonationLetter.dot"
oApp.Visible = True

' The following code is generated from your Access form while it is
' manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word VBA.

If oApp.ActiveDocument.Bookmarks.Exists("Amount") = True Then
oApp.ActiveDocument.Bookmarks("Amount").Range.Text = curAmount
End If

Exit_Donation_Letter_Word_Click:
Exit Sub


.
 
Try curAmount = Format(Forms![Donor-Registration Form-US]![individual
donations subform]!Amount,"currency").

Ian King



Meryl said:
I have a donations template letter that I have in Word. From access I
want to pass the amount and insert it into the letter
using a bookmark. All goes well, but I lose the currency formatting. For
numbers 1,000 and above, no comma appears in the word document and I can't
figure out why. When I export data from the same table into Excel, I see
both the comma and the dollar sign. Can you tell me what is wrong with the
code below? Thank you. Meryl
Private Sub Donation_Letter_Word_Click()
On Error GoTo Err_Donation_Letter_Word_Click

Dim oApp As Object

Set oApp = CreateObject("Word.Application")
oApp.Visible = True

Dim curAmount As Currency
curAmount = Forms![Donor-Registration Form-US]![individual donations subform]!Amount

' Open Microsoft Word using automation


oApp.Documents.Add "C:\Windows\Application Data\Microsoft\Templates\RegDonationLetter.dot"
oApp.Visible = True

' The following code is generated from your Access form while it is
' manipulating an instance of Word.
' So, while it looks somewhat like VBA, it's really Word VBA.

If oApp.ActiveDocument.Bookmarks.Exists("Amount") = True Then
oApp.ActiveDocument.Bookmarks("Amount").Range.Text = curAmount
End If

Exit_Donation_Letter_Word_Click:
Exit Sub
 
Back
Top