merge with MS Access query underlying

S

Sam

I have the following code which opens a word document from MS Access 2003:

Dim LWordDoc As String
Dim App As Object

'Path to the word document
LWordDoc = "c:\ServerBackup\rptBUMC HxP.doc"

If Dir(LWordDoc) = "" Then
MsgBox "Document not found."

Else
'Create an instance of MS Word
Set App = CreateObject(Class:="Word.Application")
App.Visible = True

'Open the Document
App.Documents.Open filename:=LWordDoc
End If

The document is a mail merge document set up that way so I can populate it
with various data from my database. When I open the document, the underlying
query that populates the Word document (from MS Access) does not update. If I
open the document directly from Word, the query updates. Furthermore, if I
manually refresh the query in Access, the Word document still doesn't
refresh: it keeps the old data. How can I correct this?

Sam
 
P

Peter Jamieson

1. Have you made the registry change described in

http://support.microsoft.com/kb/825765

?
Furthermore, if I
manually refresh the query in Access, the Word document still doesn't
refresh: it keeps the old data. How can I correct this?

In the user interface you may be able to open the Edit Recipients dialog
box and click Refresh. Programmatically, I do not know how you can do it
- at least not reliably. Possibilities - and that is all they are as I
have not investigated - include
a. changing the activerecord to be an earlier record than the current one
b. modifying the querystring, then reverting to the original one
c. closing and re-opening the data source
d. closing and re-opening the mail merge main document

(b), (c) and (d) would probably have to be accompanied by code to deal
with side-effects of modifying the data source.

Peter Jamieson

http://tips.pjmsn.me.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top