Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access to Word Mail Merge One Record

Status
Not open for further replies.

charle525

MIS
Jul 18, 2003
23
0
0
US
I am trying to use a form button to open a Word MailMerge document and populate it's Merge fields with the data from only the record showing on the form. I generated the following code to do this by recording a macro in Word.

ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\StudentServices\StudentServices8_28.mdb", ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\StudentServices\StudentServices8_28.mdb;Mode=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB" _
, SQLStatement:="SELECT * FROM `tblStudents`", SQLStatement1:="", _
SubType:=wdMergeSubTypeAccess

This code works to open all records from tblStudents as shown in the SQLStatement:= . . . argument of the function. However, when I add a WHERE clause to the SQL I get the following error: "Remote Server not found or Remote Server unavailable"

Any idea why this is error and what to do about it? Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top