PDA

View Full Version : HELP: Access Button Print Mail Merge Word Doc



RobertBC
04-02-2009, 11:53 PM
Good Day!

I have a merge document created in word since the data source is on ms access (im using 2003) i want to create a form on access and set a command button that merge the documents (print and file) can someone not too busy give me a example of such word documents, access data source and a code for the cmd button.


tnx a lot!

CreganTur
04-03-2009, 05:18 AM
I want to double-check your requirements first, to ensure that we're talking about the same thing.

You want a button on your form to open a Word document, and then run a mail merge on it based on a query or table within your database? Is this what you're looking for?

jaykishan_82
04-11-2009, 01:41 AM
Send me your requirements as i have created the same process recently.

RobertBC
04-18-2009, 05:02 PM
Thanks for your time
I attach a simple merge doc with its data source can you pls help me fill up the command button code to print the merge document ( all, selections from to)

tnx again

jaykishan_82
04-20-2009, 09:17 AM
I Have attached the same database file for your reference. Hope this will answer more than your requirement.

Regards,

Jaykishan Choube

CreganTur
04-20-2009, 09:33 AM
You can use this code to mail merge records in a query to a document. Just feed it the filepath to your document and the name of the query:

Sub OpenLetters(strFilePath As String, strQuery As String)

Set objWord = New Word.Application
objWord.Visible = True
Set objDoc = objWord.Documents.Open(strFilePath)
'mail merge
objDoc.MailMerge.OpenDataSource Name:="C:\FC_Letters\FC_Letters.mdb", LinkToSource:=True, _
AddToRecentFiles:=False, Connection:="QUERY " & strQuery, _
SQLStatement:="SELECT * FROM [" & strQuery & "]"
objDoc.MailMerge.ViewMailMergeFieldCodes = False

End Sub

HTH:thumb

RobertBC
04-20-2009, 07:43 PM
tnx guys im trying out every sugestions you made thans again for the time after finished my work i will post it here for the code reference.... :)