Thank you Duane.
It inserts all the data from the access table/query to a new word document.
One last question, is it possible to use the same or similar code to insert the full data from the table/query to a document which already has some text in it....i mean say for example if there is a word document named myword.doc which has some text in it.....and somewhere in between that text, the data from the query should be inserted AUTOMATICALLY when i click a button on access form. I know how to create the form and the button.
This is the code i am using in the module to do the mail merge for one of the requirements, "complaint":
Code:
Public Function Complaint()
On Error Resume Next
Dim wks As Word.Document
DoCmd.Hourglass True
Set wks = GetObject(Application.CurrentProject.Path & "\forms\Complaint.doc")
wks.Parent.Visible = True
wks.MailMerge.DataSource.FindRecord Forms!menu!Combo9, "ID"
Set wks = Nothing
' Set the Word Object to nothing to free resources
DoCmd.Hourglass False
Exit Function
End Function
This code opens the word document which i merged with a table, and pulls the data from the table for a particular ID on the "Menu" form.
I was using the similar code for my current requirement, but as you know, it opens the word document but has only one record, and have to click "next record" button on mailmerge toolbar for getting next records on the word document.
My question is that: can i insert all the data from the access table/query to the word document at once, in between the text in the word document.
For example: Lets assume the following is the word document:
----------------------------------------------------------
To
The DMV,
This is the data which we have on our records
< all the data from the table/query should be inserted here>
Thank you,
John Walter
Office of ISS
------------------------------------------------------------
Hope you understood my problem.
Thanks Duane,
Vik