I never got it to work the way the book example showed. Another thread for this problem is:
http://p2p.wrox.com/topic.asp?TOPIC_ID=36365
(Other Forum members had some ideas that may work for you). Perhaps it has to do with my db being in A2K........ and the example was for Access 2003.
However, I used a work-around which gets me what I wanted. I've taken the PK from the form user is on, and set the WHERE of the query that will underly the Word DOT to be merged through the querydef collection.
For this to work the target WOrd documents MUST be .DOTs and they MUST be set up as mail merge documents with their OpenDataSource set to the target query.
THis has really saved us alot of time as well as allowed staff who can create WORD docs to create the templates and mail merge docs.
It also is easy for us to then customize letters that are otherwise form letters. (It was worth the sweat).
HTH,
Loralee
*****************************
Private Sub cmdMergeLetter_Click()
' this is an attempt to open a Word document and start a mail merge
Dim strFilePath As String
Dim objWord As Word.Document
Dim strPatientID As String ' use to link to PK of the form this launches from
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
Dim strSQLMerge As String
strPatientID = Forms!frmpatientdata.txtPatientID ' launch from this form
strSELECT = "SELECT tblPatient.[PatientID], tblPatient.[PtFirstName], tblPatient.[PtLastName], tblPatient.[PtBD], tblCity.[City], tblPatient.[PtAddress], tblPatient.[PtZip], tblReferral.[ReferBy]"
strFROM = " FROM (tblCity INNER JOIN tblPatient ON tblCity.[CityID] = tblPatient.[PtCityFK]) INNER JOIN tblReferral ON tblPatient.[PatientID] = tblReferral.[PtFK]"
strWHERE = " WHERE ((([PatientID])= " & strPatientID & "))"
strSQLMerge = strSELECT & strFROM & strWHERE
CurrentDb.QueryDefs("qrymailmerge").SQL = strSQLMerge
Me.cmdlg.DialogTitle = "Choose File Name and Location"
Me.cmdlg.ShowOpen
strFilePath = Me.cmdlg.FileName
Set objWord = GetObject(strFilePath, "Word.document")
' make word visible
objWord.Application.Visible = True
' execute the mail merge
objWord.MailMerge.Execute
objWord.Close
End Sub