Access Data To MS Word

fenhow

Registered User.
Local time
Today, 12:23
Joined
Jul 21, 2004
Messages
599
Hello,

I have created a MS word document in Word 2003, I have created the merge features pointing to my DB and it works great. I mean works great from Word to Access.

I am looking for a way to open the Word document from a button in the Access form that will open the document showing the data from the record that I am executing the word document from?

Can anyone offer any assistance please?

Thanks,
Fen
 
This has been covered numerous times. Search the forum for Word Object and you should be able to decduce from that information what you are trying to do.
 
Found Solution However About Null Values?

Hi, I did find a workable solution however I have only one snag, if the field on the form has a null value it halts. Is there any piece of code I can add to allow null values to pass? Below is an example of the code I am using.

Private Sub Command118_Click()

Dim objWord As Word.Application
Dim wrdDoc As Word.Document
Dim strPath As String


strPath = "G:\ALL GENESIS\ALL CLIENTS\SABINE ENTERPRISES\LEASE FORMS\FISHERLPR.doc"
Set objWord = New Word.Application
With objWord
.Visible = True
.WindowState = wdWindowStateMaximize
End With
Set wrdDoc = objWord.Documents.Open(strPath, , False, False, , , , , , , , True)

wrdDoc.FormFields("ls_Prospect").Result = Forms!frmLPR.[ls_Lessor]
wrdDoc.FormFields("ls_County").Result = Forms!frmLPR.[ls_County]
wrdDoc.FormFields("ls_Tract_No").Result = Forms!frmLPR.[ls_Tract_No]


Set objWord = Nothing

End Sub
 
Add an NZ function to each passed value. Here's what it would look like on the first one in your code sample:


wrdDoc.FormFields("ls_Prospect").Result = Nz(Forms!frmLPR.[ls_Lessor],"")

The NZ function says, "If this value is NULL, convert it to whatever is after the comma." In this case, we convert it to an empty string.
 
Excellent! Thanks, one more tiny thing

Any idea how I can get the word document to open to the screen when I execute the code?

It opens the document however it stays on the "Start Bar" in a minimized status.

I would like it to open up infront of me.

Thanks.

Fen
 
Try:
objword.activate

Should work. Worked for me linking from Excel.
 
Problem Refreshing New Data

On the above mentioned code, it works well however when I go to a new record and try to run the Word Document my data does not change, only a few fields update?

Any Ideas why? anyone?

Thanks.
 

Users who are viewing this thread

Back
Top Bottom