dbTalk Databases Forums  

Mail merge from Access 97 to Word 2003

comp.databases.ms-access comp.databases.ms-access


Discuss Mail merge from Access 97 to Word 2003 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gina
 
Posts: n/a

Default Mail merge from Access 97 to Word 2003 - 09-15-2011 , 07:27 AM






I am trying to merge membership data from my Access 97 database to a
form letter in Word 2003. I have a form which contains members'
personal details. A button on this when clicked opens a dialog box,
allowing me to enter certain specific data (e.g. date the letter will
be despatched which could be days later and date of expiry of new
membership). From a button on the dialog box, I then launch the merge
process with this code:

Private Sub cmdPrintSingleVCard_Click()
Dim objWord As Word.Document, strMergeDoc As String, strSQL As String

On Error GoTo Err_cmdPrintSingleVCard_Click
strMergeDoc = "Q:\Databases\Volunteers\14v0.2gProduction
\VolunteerCardTemplate.doc"

strSQL = "SELECT tblVolunteers.fldContactIDNew,
Format([fldDateVCardIssued],""d mmmm yyyy"") AS IssueDate,
Format([fldDateVCardExpires],""d mmmm yyyy"")"
strSQL = strSQL & " AS ExpiryDate, tblVolunteers.fldCurrent,
tblVolunteers.fldTitle, tblVolunteers.fldInitials,
tblVolunteers.fldForenames, tblVolunteers.fldSurname,
tblVolunteers.fldAddress1Main, "
strSQL = strSQL & " tblVolunteers.fldAddress3Main,
tblVolunteers.fldAddress2Main, tblVolunteers.fldTownMain,
tblVolunteers.fldPostCodeMain, tblVolunteers.fldCountyMain "
strSQL = strSQL & " FROM tblVolunteers WHERE
tblVolunteers.fldContactIDNew =[forms]![frmPrintSingleVCardDialog]!
[txtCurrentID];"
Debug.Print strSQL
Debug.Print strMergeDoc


Set objWord = GetObject(strMergeDoc, "Word.Document")

objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource Name:="Q:\Databases\Volunteers
\14v0.2gProduction\cltWSBVol.mdb", LinkToSource:=True,
Connection:="QUERY Query1", SQLStatement:=strSQL

objWord.MailMerge.Execute

…error code etc

End Sub


Immediately I get an access error message saying "String is longer
than 255 characters". The Word template opens in the background, of
course with no merged data, just showing the merge fields. I check
the debug.print output and strSQL is fine when pasted into a new query
and the template is being picked up correctly.

Any ideas where I am going wrong?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.