Printing WORD docs from a form

G

Greg Casper

I have a button on a form and I want it to print a Word mail merge document
that contains data from the database that is linked to my application.

I'm using the following code but always get a 5922 error - Word can't
open the source... All variable names contain valid data, so that's NOT
the problem.

With appWord
.Visible = True
.Documents.Open pathdocname
With .ActiveDocument.MailMerge

.MainDocumentType = wdFormLetters
strConnection = "DSN=MS Access Databases;" _
& "DBQ=" & strFileName _
& "FIL=RedISAM;"
.OpenDataSource Name:=strFileName, LinkToSource:=True,
ReadOnly:=True, _
Connection:=strConnection, _
SQLStatement:="SELECT * FROM People WHERE !ContactID =
People.ContactID"
End With


Even if I take out the WHERE clause, it doesn't work. It just won't
connect.

WHAT AM I DOING WRONG???

Thanks folks...
 

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