Link word document to database table in access

G

Guest

I print letters from my access database using words mail merge feature. I can
easily open word documents from access with a command button. however I want
to know if it is possible to somehow tell word which database and table to
link to. Otherwise people have to use the mail merge wizard to select the
proper table and they always have trouble. I don't know if its possible or
if i have to do some code in the word document itself. any help is
appreciated. thanks

keith
 
G

Guest

Ok so I found a way to do it but I'm still having problems. here is my code:

Private Sub test_Click()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Program Files\School Database\JRAM Tuition
Statement2.doc")
objWord.Application.Visible = True

objWord.MailMerge.OpenDataSource _
Name:="C:\Program Files\School Database\" & _
"RyeNursery.mdb", _
LinkToSource:=True, _
Connection:="TABLE tblSRPM", _
SQLStatement:="SELECT * FROM [tblSRPM]"

objWord.MailMerge.Execute
End Sub

It opens the word document however i get this message "test conection failed
because of an error in initializing provider. The database has been placed in
a state buy user 'Admin" on machine "my computer" that prevents it from being
opend or locked." Then access reports the same message. once i get this
working i would like word to start the mail merge wizard on step 3 so the
users can select their own recipients. any help is greatly appreciated. thanks

keith
 

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