bluedollar
Programmer
I have a mail merge that is not working, the code I am using is shown below ([sf18_data] is a query):
DoCmd.RunCommand acCmdSaveRecord
Dim oDoc As Word.Document
Set oDoc = GetObject("C:\sf18.doc", "Word.Document"
oDoc.Application.Visible = True
oDoc.MailMerge.OpenDataSource _
Name:="c:\windows\desktop\select.mdb", _
linktosource:=True, _
Connection:="QUERY sf18_data", _
SQLStatement:="Select * From [sf18_data] where [sf18_data].ID = " & Me.Text95
oDoc.MailMerge.Execute
DoCmd.Close acForm, "sf18", acSaveNo
At the moment I get the following error message:
error: 5922 Word was unable to open the datasource
If I change the SQlstatement to:
SQLStatement:="Select * From [sf18_data]"
Then the merge works fine, however all the records in the recordset are merged.
Also a new copy of the select.mdb is opened, is there any way to prevent this.
Any help would be greatly appreciated.
Thanks
Dan
DoCmd.RunCommand acCmdSaveRecord
Dim oDoc As Word.Document
Set oDoc = GetObject("C:\sf18.doc", "Word.Document"
oDoc.Application.Visible = True
oDoc.MailMerge.OpenDataSource _
Name:="c:\windows\desktop\select.mdb", _
linktosource:=True, _
Connection:="QUERY sf18_data", _
SQLStatement:="Select * From [sf18_data] where [sf18_data].ID = " & Me.Text95
oDoc.MailMerge.Execute
DoCmd.Close acForm, "sf18", acSaveNo
At the moment I get the following error message:
error: 5922 Word was unable to open the datasource
If I change the SQlstatement to:
SQLStatement:="Select * From [sf18_data]"
Then the merge works fine, however all the records in the recordset are merged.
Also a new copy of the select.mdb is opened, is there any way to prevent this.
Any help would be greatly appreciated.
Thanks
Dan